- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-25-2022 02:09 AM
I need to access the ritm variables in the catalog client script.
there is a field called "Select RITM" referencing sc_req_item in one of the catalog item.
When a user selects an ritm from the above field, there should be an alert for "Billing rate" field value in that ritm selected.
Billing rate field is on the catalog item,its not on the ritm form.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-25-2022 02:30 AM
Hi,
you can use onChange + GlideAjax
onChange catalog client script on that variable "Select RITM"
UI Type - ALL
Applies on Catalog Item - True
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(oldValue != newValue){
var ga = new GlideAjax('checkRecords');
ga.addParam('sysparm_name', "checkRecordPresent");
ga.addParam('sysparm_ritm', newValue); // give here user_id variable name
ga.getXMLAnswer(function(answer){
if(answer != ''){
alert("Billing Rate Value is " + answer);
}
});
//Type appropriate comment here, and begin script below
}
}
Script Include: It should be client callable
var checkRecords = Class.create();
checkRecords.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkRecordPresent: function(){
var id = this.getParameter('sysparm_ritm');
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id', id);
gr.query();
if(gr.next()){
return gr.variables.billingRateVariableName; // use valid variable name here
}
},
type: 'checkRecords'
});
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-25-2022 02:24 AM
Hello Bharath,
have you tried current.variables.<variable name>?
Regards, Ivan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-25-2022 02:25 AM
Hi,
I cannot use current, because I am not writing the code for the current ritm record.
My question is :
How to access RITM variables via script when your RITM is not the current record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-25-2022 02:27 AM
Please use g_form.getValue("variable_name")
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā08-25-2022 02:30 AM
Hi,
you can use onChange + GlideAjax
onChange catalog client script on that variable "Select RITM"
UI Type - ALL
Applies on Catalog Item - True
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(oldValue != newValue){
var ga = new GlideAjax('checkRecords');
ga.addParam('sysparm_name', "checkRecordPresent");
ga.addParam('sysparm_ritm', newValue); // give here user_id variable name
ga.getXMLAnswer(function(answer){
if(answer != ''){
alert("Billing Rate Value is " + answer);
}
});
//Type appropriate comment here, and begin script below
}
}
Script Include: It should be client callable
var checkRecords = Class.create();
checkRecords.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkRecordPresent: function(){
var id = this.getParameter('sysparm_ritm');
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id', id);
gr.query();
if(gr.next()){
return gr.variables.billingRateVariableName; // use valid variable name here
}
},
type: 'checkRecords'
});
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader