how to get RITM variables in Client callable script include, I am attaching the picture of code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2022 05:38 AM
how to get RITM variables in Client callable script include, I am attaching the picture of code.
get_Request_Details: function() {
var array = [];
var bsid = this.getParameter('sysparm_sys_id');
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id', bsid);
gr.query();
gs.info("CHECK <<<<< 00:" + bsid);
if (gr.next()) {
var ff = gr.number;
var gf = gr.type;
var obj = {
type: gr.variables.type,
employee_type: gr.variables.employee_type,
report_to: gr.variables.report_to,
direct_reports: gr.variables.direct_reports,
preferred_first_name: gr.variables.preferred_first_name,
legal_name: gr.variables.legal_name,
work_in_location: gr.variables.work_in_location,
state_name: gr.variables.state_name,
};
}
array.push(obj);
gs.info("CHECK <<<<< :" + JSON.stringify(array) + "OBJ" + JSON.stringify(obj) +"<<<< "+ ff +"<<<< "+ gf);
I am gettiing the array object as empty log as mentioned below
[{"type":{},"report_to":{},"direct_reports":{},"preferred_first_name":{},"legal_name":{},"work_in_location":{},"state_name":{}}]OBJ{"type":{},"report_to":{},"direct_reports":{},"preferred_first_name":{},"legal_name":{},"work_in_location":{},"state_name":{}}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2022 08:32 AM
Code looks fine, its just that why don't you declare obj outside if condition, and assign values inside if.
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2022 03:43 AM
Hi Aman,
Its not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 11:16 AM
Greetings! This is a bit of an old thread, but I have seen this issue before and came up with a solution that helped me.
I created a function in a script include gave me the value I was seeking since "ritm_GR.variables.<variable_name>" was returning empty braces.
I built the function, but I found the information from somewhere on Google.
Function Name: getRITMVariableValue
Param 1: ritm_sysid > The sys_id of a RITM record (sc_req_item) as a string value.
Param 2: variableName > A string name value of a variable from a catalog item.
getRITMVariableValue: function(ritm_sysid, variableName) {
if (gs.nil(ritm_sysid) || gs.nil(variableName)) {
throw new "Error retrieving variable value";
}
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(ritm_sysid);
set.load();
var vs = set.getFlatQuestions();
for (var i = 0; i < vs.size(); i++) {
if (vs.get(i).getName() == variableName) {
return vs.get(i).getDisplayValue();
}
}
return "";
}