Make a variable mandatory on a single catalog task based on some other variable's value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2019 08:48 AM
Hi,
I have a catalog item where there are two fields - ID and Is approval required(yes/no). The id field is not visible on the form , it will be visible on catalog tasks. In the workflow there are 4 catalog tasks which are generated.
I want that when 'is approval required' is yes, ID should be mandatory on task 1. Similarly when 'is approval required' is No, ID should be mandatory on task 2.
Can someone help me on how to achieve this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2019 06:49 AM
It sounds like approval_required determines which second task gets generated. We can change the conditions on the g_scratchpad check to include both tasks. For this example, I am using Task 2a and Task 2b as the Workflow Activity names:
- Make Variables Mandatory on Close
Execute if True:
function onCondition() {
if (g_scratchpad.wf_activity == 'Task 1') {
if (g_form.getValue('variables.approval_required') == 'Yes') {
g_form.setMandatory('variables.id', true);
}
}
if (g_scratchpad.wf_activity == 'Task 2a' || g_scratchpad.wf_activity == 'Task 2b') {
if (g_form.getValue('variables.approval_required') == 'No') {
g_form.setMandatory('variables.id', true);
}
}
}
- Close Task
Script:
function closeTaskCheck() {
if (g_scratchpad.wf_activity == 'Task 1') {
if (g_form.getValue('variables.approval_required') == 'Yes') {
g_form.setMandatory('variables.id', true);
}
}
if (g_scratchpad.wf_activity == 'Task 2a' || g_scratchpad.wf_activity == 'Task 2b') {
if (g_form.getValue('variables.approval_required') == 'No') {
g_form.setMandatory('variables.id', true);
}
}
gsftSubmit(null, g_form.getFormElement(), 'close_task');
}
if (typeof window == 'undefined') serverCloseTask();
function serverCloseTask() {
current.state = 3;
current.update();
}
If this is still failing, please provide screen shots of what you have built so we can analyze.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2019 05:34 AM
prabhmeet
You can configure your catalog item and create a UI Policy that only applies to the Catalog Task. Below is an example of one we have in our environment that only applies on the Task. Basically it makes the sql_location_field visible and mandatory if the sql_database field is "Yes". In order for this to work, the SQL Database field must be on the task I want the UI Policy to run against. If the SQL Database field was not on the task that the SQL Location field was on this would not work.
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2019 10:46 AM
Hi, how would this work when if, sql_database field is "No" on first task and I want sql_location_field to be mandatory on the second catalog task generated.