How to set variable to Mandatory and visible on Task1, once task closed, Set it to Read only for all other tasks

Flybook
Tera Expert

Hello Experts!

I have a service request workflow set up where i have few catalog tasks created. I want variable 1 set to mandatory and visible for TASK 1, Stage "fulfillment 1" . Once the task is closed, i want Variable 1 to be read only for the rest of the workflow stages.

Trying to achieve this with UI policy. I have condition set: If variable 1 is not empty: set it to read only

Which works fine but once variable is filled with value, it is not editable (in case need changes before closing the Task)

 

Can we use stages to separate the two, and then the ui policies can look to the stage for when they should make those fields read-only?

 

If so, how can i achieve this?

Please advice!

Thank you!

1 ACCEPTED SOLUTION

Can you share your script - this should be onLoad.  The script doesn't specify whether the variable is populated, or the State of the task, it's just a straight 'If the task form being display is this certain task, the variable is mandatory, otherwise it's read-only'.  If you're seeing the variable change to read only once a value is entered then you have another client script or UI policy affecting this variable.  If the variable definition specifies mandatory = false as it should, and no other scripts or policies are working against this script, then the script I provided is all you need.

View solution in original post

5 REPLIES 5

Hello Brad,

I was able to achieve this with ui policy.

I use stages to separate the two, and then the ui policies can look to the stage for when they should make those fields Mandatory, Visible and read-only.
 
function onCondition() {
if (g_scratchpad.wf_activity == 'Workflow activity task 1' ){

g_form.setMandatory('variable 1', true);
g_form.setDisplay('variable 1',true);

}
if (g_scratchpad.wf_activity == 'workflow activity task 2' ){

g_form.setMandatory('variable 2', true);
g_form.setDisplay('variable 2',true);

}
 
2nd UI Policy for Read only:
 
function onCondition() {
if (g_scratchpad.wf_activity == 'Workflow activity task 1'){

g_form.setReadOnly('variable 1', true);
g_form.setDisplay('variable 1', true);
}
if (g_scratchpad.wf_activity == 'workflow activity task 2'){

g_form.setReadOnly('variable 2', true);
g_form.setDisplay('variable 2', true);
}
 
 
Your advice did help me to achieve this. 
 
Truly appreciate it.
Thank you!