The Zurich release has arrived! Interested in new features and functionalities? Click here for more

rohantyagi
ServiceNow Employee
ServiceNow Employee

When you move to Service Portal, there is a possibility that the client scripts defined on catalog items and record producers do not work on Service Portal. The reason is that Service Portal is a mobile framework and when you created the scripts on platform few months or years ago you didn't consider if the script should apply to mobile platform as well. If you were not using the ServiceNow native mobile app, then it is more likely to happen. The good news is that you don't have to write more code in your client scripts to make it compatible for Service Portal, it is just a simple configuration change.

find_real_file.png

What to do when Catalog Client Scripts do not work on Service Portal

You need to go back to the definition of client script and make it available for Mobile or both Desktop and Mobile. Yes, it's that simple. Follow the steps below, and keep in mind that in some older versions the selection options will be different.

  1. Navigate to Maintain Items in the Filter Navigator and select the catalog item where you defined the client script.

    Service catalog portal script.jpg

  2. Click on the options button (hamburger icon) and select Configure > Client scripts.

    Service catalog portal script 1.jpg

  3. On the definition of catalog client script, you need to change the value of field: "UI Type" to either "All" (if using both platform and Service Portal) or "Mobile/Service Portal" (if using only Service Portal)

    Service catalog portal script 2.jpg

In some old versions, the value options may look like this. Either select "Both" (if using both platform and Service Portal) or "Mobile" (if using only Service Portal)

Service catalog portal script 3.jpg

While you should make sure that the script is applicable on Mobile UI type, you must also make sure the script is compatible with the mobile scripting or Portal supported APIs.

You can use onLoad, onChange, and onSubmit client scripts.

  • addDecoration(fieldName, icon, title)
  • addErrorMessage(message)
  • addInfoMessage(message)
  • addOption(fieldName, value, label, index)
  • clearMessages()
  • clearOptions(fieldName)
  • clearValue(fieldName)
  • getActionName()
  • getBooleanValue(fieldName)
  • getDecimalValue(fieldName)
  • getDisplayValue(fieldName)
  • getEncodedRecord()
  • getFieldNames()

find_real_file.png

Using Client Scripts on Variable Editors and Order Guides

Since we are on the Catalog client scripts, let me clarify one last thing. If you have selected the checkbox for "Applies on requested Item" or/and "Applied on catalog tasks" to make it work for Variable Editors, then you may run into an issue with the variable editor.

catalog client script.jpg

Unfortunately, it won't work on Service Portal because vEditor or default Variable Editor is not yet supported on Service Portal. We are working on it, appreciate your patience while we fix it   🙂 

If you use Order Guides and do item variable assignments, that won't work on Service Portal. There will be huge changes in Service Catalog's default behavior on Service Portal in the next upcoming release, so stay tuned. I will definitely brag about it.

1 Comment