
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2019 07:28 AM
Hi All,
I am just getting my hands dirty in servicenow development. I am facing an issue with the client script execution on the portal.
I have a business requirement to make the RITM variables in the catalog requested items read-only after submission.
I have a client script that does makes the variables read-only. The script works for the ITIL view, however on the portal the get the below error
I have an OnLoad, UItype=Al client script on the sc_req_item as below
function onLoad() {
//Type appropriate comment here, and begin script below
g_form.setVariablesReadOnly(true);
}
I get the below error on the portal when approver clicks the (i) beside the RITM and the RITM view opens up. The view is editable as well.
js_includes_sp.jsx?v=09-05-2018_1933&lp=Wed_Jan_02_11_47_43_PST_2019&c=5_49:66080 (g_env) [SCRIPT:EXEC] Error while running Client Script "Make Variable editor read only": TypeError: g_form.setVariablesReadOnly is not a function
Looking forward for any help.
Thanks in anticipation.
Solved! Go to Solution.
- Labels:
-
Service Catalog
-
Service Portal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2019 07:40 AM
Set the UI type to Desktop which makes the script to run only in native view
setVariablesReadOnly is not supported in service portal
Edit: Below thread might be helpful

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2019 07:40 AM
Set the UI type to Desktop which makes the script to run only in native view
setVariablesReadOnly is not supported in service portal
Edit: Below thread might be helpful

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2019 08:21 PM
I Set the UI Type to read only and that worked.
I am trying to understand the solution provided by tim2222. I am still learning the coding part. This one is pretty detailed.
Thank you dvp!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2019 04:35 PM
There are many Client script methods that work in Platform that dont work in the Portal.
These links will help you find most of them:
Service Portal and client scripts | ServiceNow Docs
CMS to Service Portal transition (Scripts that are CMS only are also Platform only)
But when observing an error "g_form.someMethod is not a function" that means the Service Portal version of the g_form API doesnt recognise the method, and you need to use a different one.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2019 08:21 PM
Really helpful Luke. Thank you