- 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
ā03-13-2024 07:45 AM
What if you need to change the variable whose value you need dynamically?
if(condtition){
variable = variable1
}else{
variable = variable2
}
gr.variables.getValue('variable'). <-- this does not work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā03-13-2024 07:54 AM
What if the variable whose value you need is dynamic?
var variable;
if(condition){
variable = variable1
}else{
variable = variable2
}
gr.variables.getValue(variable); <-- this does not work