Solved

Is it possible to show/hide fields (setControlVisibility) or set some fields as required/not required (setControlRequired) on the FSM Smart Client Screen using Client Script?

  • 17 April 2020
  • 3 replies
  • 476 views

Userlevel 3
Badge +8

Is it possible to show/hide fields (setControlVisibility) or set some fields as required/not required (setControlRequired) on the FSM Smart Client Screen using Client Script?

 I want to set some fields as not required based on the task_type on the TASK screen, so that I do not get the validation error when saving. 
If task_type = A set user_def1 as required 
else if task_type = B set user_def1 as not required

icon

Best answer by Lee Pinchbeck 29 June 2020, 10:29

View original

3 replies

Userlevel 7
Badge +24

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

Userlevel 3
Badge +8

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

Userlevel 7
Badge +24

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

Reply