- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2020 06:26 AM
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!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2020 12:36 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2020 06:43 AM
You can achieve this with a catalog client script something like this
if(g_form.getValue('short_description') == 'TASK 1'){ //replace with the short description for this task
g_form.setMandatory('v_variable_1', true); //replace with the correct variable Name
}
else{
g_form.setReadOnly('v_variable_1', true);
}
If you want to make it more robust to cover future possible requirements across various catalog items, make it a client script running on sc_task, then add a line at the beginning
if(g_form.getValue('request_item.cat_item') == '033b6412db614340262950a45e961913'){ // sys_id of the catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2020 12:21 PM
Hello Brad,
Thank you for responding.
I tried with the above script but didn't achieve what i was looking for.
It does make it read only once value is entered but i want it to be editable until task is closed.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2020 12:31 PM
Hi BPatel,
You have to write an OnLoad Client script in which you have write the script as:
if(g_form.getValue('short_description') == 'first task'){ //short description of taks
g_form.setMandatory('v_variable_1', true); //variable 1st name
g_form.setReadOnly('v_variable_1',false);
}
else{
g_form.setMandatory('v_variable_1', false);
g_form.setReadOnly('v_variable_1', true);
}
If it helps then please mark my answer Correct and Helpful.
Thanks,
CB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-11-2020 12:36 PM
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.