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

Is there a unique field on your catalog task form to identify which TASK it is?

 

-Pradeep Sharma

Not other than the short description containing "UAT Testing Task".  I could probably add and hide a field that simply says "UAT Task" that's a checkbox or something, correct?  Unless there is a way to filter that script off of short description containing "UAT Testing Task".  I'm not great with scripting yet.  My apologies. 

Here you go. The below script is based on whether short description contains UAT Testing Task description or not.

 

function onSubmit() {
var action = g_form.getActionName();
var shortDescrition = g_form.getValue('short_description');
if(g_form.getValue('state') == '3' && action == 'close_sc_task' && shortDescrition.indexOf("UAT Testing Task") != -1)
{
g_form.setMandatory('variables.workflow_progression', true);
return false;

}

}

 

-Pradeep Sharma

It seems to be working for what I wanted, however now it keeps telling me my work notes need to be filled out(it is not blank and is filled out).  Do I need to include the work notes field in the line with:  

if(g_form.getValue('state') == '3' && action == 'close_sc_task' && shortDescrition.indexOf("UAT Testing Task") != -1)

 

 

Do you have UI Policy/Client Script which is throwing that message? I mean you can include the line g_form.get mandatory('work_notes' false) in the script to deactivate the mandatory field but I would recommend you to refer the Client Script or Ui Policy and check why it is throwing alert again and again.

 

-pradeep Sharma