tiagomacul
Giga Sage

client Script set all fields to Mandatory & Visible

UI Action / UI Policy

 

//For to set mandatory false (campos como - não obrigatório)
for (var i = 0; i < g_form.elements.length; i++)
{
    var el = g_form.elements[i];
    var fieldName = el.fieldName;
    g_form.setMandatory(fieldName, false);
}

 

 

image

summary

Script Summary

 

 

Comments
Ashley Snyder1
Giga Guru

Is this a question?  

UI Policies are the recommend method of setting fields to mandatory/visible/etc. rather than Client Scripts per ServiceNow best practice.

"When possible, consider using a UI Policy to set field attributes to mandatory, read-only, or visible. No scripting is required to set field attributes in UI Policies."

https://developer.servicenow.com/dev.do#!/guides/paris/now-platform/tpb-guide/client_scripting_techn...

Version history
Last update:
‎08-21-2020 07:16 AM
Updated by: