UI Policies using scripted methods do not work on Service Portal or Mobile. UI Policy scripts do not execute on a catalog item opened in Service Portal in a scoped application, throwing the following JS error when the catalog item is loaded:

Could not load UIPolicy script for policy


Steps to Reproduce

1. Create a scripted UI policy for any table. Ensure it will run on mobile or Service Portal.
2. Open the form for that table in Service Portal. Notice that there are JavaScript errors, and the script was not properly escaped.

1. Select a specific application in the application picker.
2. In a catalog item, create a catalog ui policy with a script runnable in both portal and desktop.
3. Open the catalog item from the portal. Notice the script does not run and the error message below shows in the JavaScript console:
[UI:SCRIPT_FALSE] Could not load UIPolicy script for policy

1. Create a catalog item.
2. Create a UI Policy and enable "Run scripts" and "Run scripts in UI Type" set to "All".
3. On the "Execute if True" section add the following script:
function onCondition() {
function callAlert() {
alert("calling custom function");
4. Open the catalog item on Service Portal. The UI Policy is not executed with no alert box, and the following console errors are logged:
(g_env) [UI:SCRIPT_TRUE] Could not load UIPolicy script for policy <UI Policy Name>
UI policy script error: TypeError: Cannot read property 'execute' of undefined


This problem is fixed in Madrid. Please review the Fixed In section to determine the latest available patch your instance can be upgraded to.

On instances that can not be upgraded yet, it is possible to set isolate script to false to resolve this issue for globally scoped UI Policies.

If the custom function is defined within the onCondition function block, the UI policy is executed. For example:

function onCondition() { 
 function callAlert() { 
alert("calling custom function"); 

Related Problem: PRB1279803

Seen In

There is no data to report.

Fixed In


Associated Community Threads

There is no data to report.

Article Information

Last Updated:2019-06-27 09:07:39