mohankrishna1
ServiceNow Employee
ServiceNow Employee

If you have seen a few Requested Item records intermittently created with no Variable data. It could be because you might be initializing to a new catalog form.

This behavior can be caused by server.update() on the client script of the SC Catalog Item widget before submitting the catalog item. This server.update() is essentially used to perform some service side action for additional functionality on Catalog Item widget.

find_real_file.png

server.update() re-Initializes the catalog form

Once the variable values are filled for a catalog item in Service Portal, These values are stored in the angular scope. However, When you perform a server.update() after filling in these variables the Server script is rerun and initialize the catalog form.

Note: After calling server.update() the client script’s data object is automatically overwritten with the server’s data object.

Since these variables values in DOM and $scope are single way bound, The end user will still see the values on Catalog Form UI but when submitting the end user is submitting a new Catalog item form (initialized by server.update()). Thus, fulfillers will see empty RITMs created without any values

Resolution:

Switch to OOB SC Catalog Item widget, If you don’t know already follow the steps below,

  1.  Navigate to <yourInstance>.service-now.com
  2. Navigate to sp_page_list.do
  3. Filter by Page ID, here it is “sc_cat_item”
  4. Open the widget instance associated to the SC Catalog Item Widget

find_real_file.png

5. In the widget Instance record,  Change the widget field from Custom SC Catalog Item widget to SC Catalog Item Widget

find_real_file.png

Possible Workaround:

1. Add a conditional wrapper around the OOB Server Script for SC Catalog item widget

  1. (function () {
  2. // Server Code of the SC Catalog Item widget
  3. if(input.<variable>){ //<variable> place holder for input variable object
  4. Perform the action initiated from the client
  5. Custom feature
  6. } else {
  7. OOB SC Catalog Item code
  8. }
  9. })()

2. Create another widget with the custom feature and perform server.update()

Additional Links:

1 Comment