This article is a supplement to the ServiceNow documentation. For full documentation please refer ServiceNow official website
Checkout our NEW Video Channel you can like and subscribe too!

Introduction

An UI Policy is a rule that applies to a form to dynamically change form information or the form itself.UI Policy Run on the client side.

Once you save the UI Policy, a new UI Policy Actions related list displays.

Through UI policy we can do three things

  1. Mandate : Making a field mandatory
  2. Visibility: Making a field visible
  3. Edit ability: Making a field Editable or Read-only.

Now lets see if we can work on this below requirement

  • Short description should be mandatory field when we will save the record
  • Updated field should be read only. We can’t edit that field
  • We make price field as hidden. 122818_1027_UIPolicy1-1.png
  1. Go to UI policies under system UI uip2.PNG
  2. UI policies is table. Where we will create a record to click on new button. uip3.PNG
  3. While working on the UI policy, we keep in mind four things
    • Table: where we will apply the UI policy.
    • Short description: it’s for our reference
    • Condition: when UI policy will get execute.
    • UI policy action: what we need to do. Once UI Policy create we will add the action uip4.PNG
  4. Every UI policy should have UI Policy Action: uip5.PNG
  5. To add the UI policy action, click on New Button uip6.PNG
  6. Our requirement is Update field should be read-only.
    • So here we select the field name Updated from the table.
    • Read only option makes true.
  7. Click on submit uip8.PNG
  8. Our requirement is Short Description field should be Mandatory.
    • So here we select the field name Short Description from the table
    • Mandatory option makes true.
  9. Click on submit uip9.PNG
  10. Our requirement is Price field should be Hidden.
    • So here we select the field name Price field from the table
    • Visible option makes true.
  11. Click on submit uip10.PNG
  12. Go to the table and see uip11.PNG
  13. Now we will apply the condition in UI policy. Condition: If the Caller field is not empty then only the UI policy will run. uip12.PNG uip13.PNG uip14.PNG uip15.PNG
  14. we can write the Java script to write the condition.
  15. Also to clear the option from the field we will write down
  function onCondition() {
      g_form.clearValue(field name);
  }

uip16.PNG

    Content