256 views

Description

UI Policies and Client Scripts on Form Widget are not honoured when the form is saved. This issue has been noticed in Kingston Patch 3.

 

Steps to Reproduce

UI Policy

1.  Create a UI Policy on the Problem table with the following settings:

  • Global and onload checked
  • Uncheck Reverse if false

2.  Create a UI Policy Action with the following settings:

  • Field name: Short Description
  • Visible: false
  • Mandatory: leave alone
  • Read Only: leave alone

3.  Access this link on Service Portal to create a new problem:

https://<instancename>.service-now.com/sp?id=form&table=problem&sys_id=-1

Observe that the field Short Description is hidden because of the onload UI Policy created in Step 1.

4. Fill in the mandatory fields and click on Save.

After the form is saved, Short Description still appears without honouring the UI Policy.

 

Client Script

1. Create a client script with the following settings:

  • Table:  Problem
  • UI Type: All
  • Type: onLoad
  • Script:  

                   function onLoad() {

                  //Type appropriate comment here, and begin script below

                   alert("Hello World");

                   }

2.  Save the client script.

3.  Access this link on Service Portal to create a new problem:

https://<instancename>.service-now.com/sp?id=form&table=problem&sys_id=-1

Observe that the alert box is displayed.

4. Fill in the mandatory fields and click on Save.

After the form is saved, the client script is not executed, and the alert box is not displayed on reload.

 

Workaround

This issue will be fixed in the next upcoming Kingston Patch 7. The workaround below has only been tested in KP3:
  1. Edit the Form Widget.
  2. Add a new dependency, provide any name.
  3. Create a new JS include for this new dependency and add a new UI Script associated to it.
  4. Copy/Paste the content of the workaround-kingston-patch3.txt file included.
 
The key code section is the following:
 
  $rootScope.$on(“sp.form.record.updated”, function() {
                $scope.$applyAsync(function() {
                    $scope.execItemScripts();
                });
            });
 
This temporary fix and the dependency should be removed before upgrading to KP7. 
 
 
 

Related Problem: PRB1270017

Seen In

Kingston Patch 3

Intended Fix Version

Kingston Patch 7
London

Safe Harbor Statement

This "Intended Fix Version" information is meant to outline ServiceNow's general product direction and should not be relied upon in making a purchasing decision. The information provided here is for information purposes only and may not be incorporated into any contract. It is not a commitment, promise, or legal obligation to deliver any material, code, or functionality. The development, release, and timing of any features or functionality described for our products remains at ServiceNow's sole discretion.

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2018-06-15 10:35:47
Published:2018-06-08