how to make field Mandatory if priority is downgraded from P1 or P2 by anyone on incident form.

Nirav
Tera Expert

Hi,

 

I have added a field called "u_justification_for_priority" (label: Justification for priority)  on incident form. I want it to be mandatory and visible only if someone downgrades the priority from P1 or P2.

 

priority downgrading.png

 

How do we achieve it?

I have tried Ui policy but UI policy does not seems to help as there is no option like priority changes to or there is no other option which can use. Please help. 

 

Thanks in advance.

1 ACCEPTED SOLUTION

Hi Nirav,

Please try this.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if ((isLoading) && (g_form.getValue('u_justification_for_priority') == '')) {
       g_form.setVisible('u_justification_for_priority', false);
      return ;
   }
	

   //Type appropriate comment here, and begin script below
	
	if((oldValue == 2 && newValue == 3)||(oldValue==2 && newValue==4))
		{
			g_form.setVisible('u_justification_for_priority', true);
			g_form.setMandatory('u_justification_for_priority',true);
		}
	else if(g_form.getValue('u_justification_for_priority') == '')
		{
			
			g_form.setMandatory('u_justification_for_priority',false);
			g_form.setVisible('u_justification_for_priority', false);
			
		}
   
}

Thanks,

Pooja M

View solution in original post

11 REPLIES 11

Below is what i used and it's working now. Thank for your help.

 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {


var val = g_form.getValue('priority');
var jfp = g_form.getValue('u_justification_for_priority');
//if (val==3 || val==4)
//g_form.addInfoMessage(oldValue);
//g_form.addInfoMessage(newValue);
if( (oldValue == 2 && newValue == 3) || (oldValue == 2 && newValue == 4) )
{
g_form.setDisplay('u_justification_for_priority', true);
g_form.setMandatory('u_justification_for_priority', true);
}
else if (jfp!=="")
{
g_form.setMandatory('u_justification_for_priority', true);
g_form.setDisplay('u_justification_for_priority', true);
}
else if (jfp=="")
{
g_form.setMandatory('u_justification_for_priority', false);
g_form.setDisplay('u_justification_for_priority', false);
}
}

PeerjadGhoB
Tera Contributor

Hi In service now the priority field is mandatory in Incident Table but it is not showing mandatory in agent workspace table. Could you help me in that