- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 12:21 PM
Hi all,
I have an On-Change client script that makes a Glide Ajax call and returns a value. The script include which is being called has a function with simple script making a Glide record on Sold Product(sn_install_base_sold_product).
The script is working fine when logged in as an admin, but when logged in as a customer it is returning "null". I figured it may be an issue with the Query rules as we have OOTB CSM query rules on Sold product table. I created a new query rule to provide read access for a particular customer role, but still the script is returning "null". Any leads or help with the troubleshooting of this issue is appreciated.
Attaching my client script and script include code for reference.
Client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
ajaxCallserial();
}
function ajaxCallserial() {
var serialNumber = g_form.getValue('product_key');
var numCheck = new GlideAjax('global.ClaimProductUtilsAjax');
numCheck.addParam('sysparm_name', 'validateSerialNumber');
numCheck.addParam('sysparm_serialNumber', serialNumber);
numCheck.getXML(handleResponse);
function handleResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
if (answer == 'false') {
g_form.setValue('response_variable', "false");
} else{
g_form.setValue('response_variable', "true");
}
}
}
Script Include:
validateSerialNumber: function() {
var serialnumber = this.getParameter('sysparm_serialNumber');
var checkNum = new GlideRecord('sn_install_base_sold_product');
checkNum.addQuery('u_sold_product_serial_number', serialnumber);
checkNum.query();
if (checkNum.hasNext()) {
return true;
} else return false;
},
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 11:43 PM
Hi @Prem5
In script include , Can you try by adding below function in script include :
isPublic:function(){
return true;
},
Foe example :
/*For example */
var yourScriptIncludeName = Class.create();
yourScriptIncludeName.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isPublic:function(){
return true;
},
/*your function */
validateSerialNumber: function() {
var serialnumber = this.getParameter('sysparm_serialNumber');
var checkNum = new GlideRecord('sn_install_base_sold_product');
checkNum.addQuery('u_sold_product_serial_number', serialnumber);
checkNum.query();
if (checkNum.hasNext()) {
return true;
} else return false;
},
type: 'yourScriptIncludeName';
});
Below link might help :
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 11:28 PM
Hi,
Check if there is any ACL
Operate - execute
Type - client_callable_script_include
Name - name of Script include
Add required roles to the ACL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 11:39 PM - edited 10-10-2023 11:39 PM
Issue is with the ACL, when we created a new client callable script include there is an ACL(operation -execute) associated with it.
Please check what role is added to that ACL, that roles should be available to the end user OR you can add another role to the ACL(the same role which customer has) to made it accessible to the end user or customer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2023 11:43 PM
Hi @Prem5
In script include , Can you try by adding below function in script include :
isPublic:function(){
return true;
},
Foe example :
/*For example */
var yourScriptIncludeName = Class.create();
yourScriptIncludeName.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isPublic:function(){
return true;
},
/*your function */
validateSerialNumber: function() {
var serialnumber = this.getParameter('sysparm_serialNumber');
var checkNum = new GlideRecord('sn_install_base_sold_product');
checkNum.addQuery('u_sold_product_serial_number', serialnumber);
checkNum.query();
if (checkNum.hasNext()) {
return true;
} else return false;
},
type: 'yourScriptIncludeName';
});
Below link might help :
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 07:19 AM
Hi @Vishal Birajdar, thank you for your input. This worked like a charm