Hi,
You should be able to achieve this using the script screen on the UI Designer of the screen in question.
You will just need to set the script to look at a field on the table the screen uses and then set the value on the appropriate field based off of the value in the check field.
Example:
var control = getDBValue("select ISNULL(user_def2,'XXXXX') from task where task_id = '" + taskId + "'");
if(isNullOrEmptyString(control))
{
setControlRequired('user_def1', true);
}
else {
setControlRequired('user_def1', false);
}
This will store the value in user_def2 as a variable and then check it as part of an if statement. If it is populated then it sets the user_def1 field to required. If not it marks it as not required.
*Note this is example script intended only for demonstration of syntax not for use in live environments*
The specifics could then be altered to be more complex. Check for specific values in the field for instance and then do multiple else ifs for multiple settings and multiple field sets can be done within one if branch.
Hope this helps,
Lee Pinchbeck
Hi,
Thanks for the suggestion but I am still not able to get it to work.
I hope you are referring to the “View Screen Events” option on the UI Designer. Can you suggest which option to choose there?
I am using the TASK_TYPE field as the control value and trying to set the required property on user_def11 field. The user_def11 is already set as required by default on the UI designer.
After applying the script on the event “AfterScreenLoad”, I still get the validation error for the required field on the screen while saving, even though the control value evaluates to false.
Thanks,
Sourabh Jain
Hi Sourabh,
This may be better suited to a Consulting Resource Request Case for the consulting team to take a look at this specific code and determine what is going wrong here. It may be something to do with the other specific setups and code running for your system.
It would likely assist if you provide the full details of the validation error along with the code you are attempting to execute.
Kind regards,
Lee Pinchbeck