- 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
ā01-30-2023 11:08 AM - edited ā01-30-2023 11:10 AM
@Ankur Bawiskar I know this has already been answered, but I am so close. How can we add a getXMLWait in the client script portion of this? I am using return false; in my client script and it's moving to quickly to stop the submission.
//Getting Gap Review Detail Variable
var ga = new GlideAjax('checkRecords');
ga.addParam('sysparm_name', "checkRecordPresent");
ga.addParam('sysparm_ritm', ritmSysID); // give here user_id variable name
ga.getXMLAnswer(function(answer){
if(answer != ''){
alert("OLD GAP OWNER VALUE: " + orig_val + " | GAP OWNER VARIABLE DATA: " + answer);
if(orig_val != answer){
alert("THEY DO NOT MATCH - SOMEONE ELSE UPDATED THEIR TASK");
return false;
}
}
});
//Type appropriate comment here, and begin script below
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-30-2023 08:35 PM
are you using the GlideAjax in onSubmit and it's not waiting till the response?
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-31-2023 10:57 AM - edited ā01-31-2023 10:57 AM
That's correct and thanks for the reply, but I figured it out using the KB from ServiceNow:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0783579
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-01-2023 06:41 AM
One last question....is it possible to modify the script include so that you don't hard code the variable to return? Maybe pass the variable name in a parameter from the client script to the Script Include?
This way the script include can be reusable by other client scripts.
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-01-2023 06:56 PM
I don't think so since every validation might be different which you are planning to do in script include function
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader