Problem calling a Script Include from a catalog client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-01-2024 09:42 PM - edited 05-01-2024 10:18 PM
Hello ServiceNow people.
I am getting following error while calling script include from catalog client script. I don't have clue. Can anybody help me out.
(running Client Script "test": ReferenceError: RestrictedOptionsUtil is not defined)
System Property:
script include:
Catalog Client Scripts :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2024 10:19 AM - edited 05-02-2024 10:44 AM
Hi @prudhvi67 ,
Make sure in your Script Include "Client Callable" is checked.
To make a GlideAjax call in a client script, you can refer to the script provided below.
// Initialize GlideAjax for the specified script include
var ajaxCall = new GlideAjax('restrictedOptionUtil');
// Add the method name to invoke from the script include
ajaxCall.addParam('sysparm_name', 'getRestrictedOption');
// Make the GlideAjax call and pass the callback function
ajaxCall.getXML(processResponse);
// Callback function to process the response from the script include
function processResponse(response) {
// Extract the 'answer' attribute from the response
var answer = response.responseXML.documentElement.getAttribute("answer");
// Display the value using an alert dialog
alert(answer);
}
If you find my response helpful, please consider marking it as the 'Accepted Solution' and giving it a 'Helpful' rating. Your feedback not only supports the community but also encourages me to continue providing valuable assistance.
Regards,
Amitoj

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2024 10:38 AM
Hi @prudhvi67 ,
You have to make a GlideAjax call in client script you can refer below script
var ga = new GlideAjax('restrictedOptionUtil');
ga.addParam('sysparm_name', 'getrestrictedOptionUtil');
ga.getXML(getValuleHandler);
function getValuleHandler(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer) // you get the value of property here
}
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak