Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

make field mandatetory field visible for only new records in incident

rameshrv999
Giga Contributor

Hi Friends,

I have created drop down box in incident i   made it as a mandatory.

Now i want make it visible   for newly creating records only, if we open existing records it should be invisible.

Please help me how to make it.

Thanks in advance

1 ACCEPTED SOLUTION

Mihir Mohanta
Kilo Sage

Control the mandatory functionality from a on load client script and disable the mandatory functionality from other places you have added.


Then write a on load client script like:



if(g_form.isNewRecord()){


  g_form.setMandatory('field_name', 'true');   ////provide field name here


}


else{


g_form.setMandatory('field_name', 'false');


}




Thanks,


Mihir


View solution in original post

4 REPLIES 4

Mihir Mohanta
Kilo Sage

Control the mandatory functionality from a on load client script and disable the mandatory functionality from other places you have added.


Then write a on load client script like:



if(g_form.isNewRecord()){


  g_form.setMandatory('field_name', 'true');   ////provide field name here


}


else{


g_form.setMandatory('field_name', 'false');


}




Thanks,


Mihir


Abhinay Erra
Giga Sage

Use g_form.isNewRecord() method.



Thanks,


Abhinay


paramveer
Mega Guru

Hi   Venkata,



Create a on-load client script on incident table and write below code :



if(g_form.isNewRecord()) {


  g_form.setDisplay('field_name', true);   ////provide field name here


  g_form.setMandatory('field_name', true);   ////provide field name here


}


else {


g_form.setMandatory('field_name', false);


g_form.setDisplay('field_name', false);   ////provide field name here


}



Also remove is there is any UI policy action applied on the same field.




~Paramveer Singh


~Senior Developer



Please mark Helpful, Like, or Correct Answer if applicable.


Midhun1
Giga Guru

Hi,



Just now i got solution:



Using onload script you can make it Mandatory:



find_real_file.png



Then using UI Policy am checking whether it is new record or not and making visibility false:



find_real_file.png



find_real_file.png




This is how it worked (Ui policies will run in the last).