UI action

Shabbir1
Tera Contributor

Hello Team,

I am new to the ServiceNow we have requirement that we have a drop down field "flag" (true or false) on the incident form if you click on the resolve button this field should become mandatory and show a pop message to fill the "flag" field without filling the "flag"  field  he/she can't resolve the incident can anyone help me in the ui action script 

2 REPLIES 2

J Siva
Kilo Patron

Hi @Shabbir1 

There is an out‑of‑the‑box  data policy configured on the Incident table that mandates the Resolution code and Resolution notes fields at the time of resolution.
You simply need to add your custom flag field to the Data Policy Rules of the existing data policy record.
JSiva_0-1776412903622.png

URL: https://<instance-id>.service-now.com/sys_data_policy2.do?sys_id=d3efcfbf3bf2320050bec9bb34efc4c2

 

Regards,
Siva

Tanushree Maiti
Kilo Patron
  1. Navigate to System Definition > Client script
  2. Create a Client Script:

    • Type: onSubmit
    • Table: incident
    Script:
    function onSubmit() {
    // Check if state is being set to Resolved //update state value as per your instance
    if (g_form.getValue('state') == '6') {
    var flag = g_form.getValue('u_flag'); // replace with your Flag field name
    if (!flag) {
    alert('Please mark the Flag checkBox before resolving the incident.');
    g_form.setMandatory('u_flag', true);
    return false
    }
    }
    }
     
     
Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: