The CreatorCon Call for Content is officially open! Get started here.

Make field mandatory before Task can be closed

booher04
Tera Guru

Hello,

I have a variable called "Workflow Progression" that is only on a certain task that fires(UAT Testing Task) from the workflow at a certain point.  The purpose of the field/variable is to ask what the workflow should do next:  Move to Production, Move to RollBack or Close the request(closed skipped).  This variable only appears on the UAT Task.  I need to figure out how to get the field to only be Mandatory when the "Close Task" ui action button is clicked.  We assign this task to different users so we need to open an update it without this field being mandatory all the time.

function onSubmit() {
if(g_form.getValue('state') == '3')
{

g_form.setMandatory('variables.workflow_progression', true);

return false;

}

}

This is what I came up with.  Any help on this?  

15 REPLIES 15

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello,

 

Is this a custom field or catalog variable on sc_task?

 

-Pradeep Sharma

This is a catalog item variable I created.  

Thanks for the update. Here you go.

function onSubmit() {
var action = g_form.getActionName();
if(g_form.getValue('state') == '3' && action == 'close_sc_task')
{
g_form.setMandatory('variables.workflow_progression', true);
return false;

}

}

so this is setting it mandatory for any catalog task and not just for a specific one(UAT).  Is there a way to set it to mandatory only on a certain TASK.  We have several different ones for the same RITM.  We use a Review task, a estimated time to complete task, a development task, UAT task, and then a move to production task.  I know that's not ideal, this was setup before I moved to this company.  The Workflow progression is only on the UAT task.