07-08-2019 09:35 PM - edited 07-08-2019 09:36 PM
Hi,
I am looking to check change turn required if another field has values:
Similar to visible I thought that something could be done
This same approach works for visible:
but not for require:
required attribute only seem to allow true/false or SESSION[...].
I wonder if there is any way I can make a field required if depending on a third field? (e.g. in my case FORM.isOnGoing)
Thank you.
Solved! Go to Solution.
07-09-2019 12:27 AM
hi,
how about a custom validator?
http://smartclient.intergraph.at/documentation/JavascriptValidation#Writing_your_own_validators
Stefano
07-09-2019 12:44 AM - edited 07-09-2019 12:44 AM
Hi,
I used to do this with a javascript function that listen to change in the third field and then set the field to required/not required. It works with GMSC 2016. You might want to try if it still works with GMSC2018.
IG.getFieldById('your_third_field').value.subscribe(function(newValue){ if(newValue==1 || newValue==2 ) { IG.getFieldById('your_field').required(true); }
07-09-2019 01:21 PM - edited 07-09-2019 01:22 PM
Hi,
Thank you for your reply.
Are you meaning to add a new resource (SCRIPT) and perform this when the form is loaded as a Custom Script?
I was looking for something in runtime. So if you click on a form field and then on the side bar you will see the 'pencil' icon on 'Required' attribute that allow you to build a javascript but :
(please open this image in a new window to see the content)
Thanks.
07-09-2019 11:17 PM
Hi,
I used it as a resource, indeed. and not in the required-configuration field.
The script will be loaded with the form (use the form:ready event for this) but because of the "subscribe" it will listen to changes in your third field.
IG.vent.on('form:ready', function(form){ IG.getFieldById('your_third_field').value.subscribe(function(newValue){ if(newValue==1){ IG.getFieldById('your_field').required(true); } }); })
But as I said, I am starting in a week to test all my workflows with GMSC 2018, so something might have changed in the API, that I haven't realized yet.