Get RITM Catalog Variable in scoped application

Ajit
Tera Contributor

Hi,

I am having scoped application. On RITM, we have catalog item with variables.

Following code perfectly works in global scope but on local scope getGlideObject is not allowed.

Please suggest alternative.

var ritmRecord = new GlideRecordSecure('sc_req_item');
ritmRecord.addQuery('request', <req_sys_id>);
ritmRecord.query();
while (ritmRecord.next()) {
  var value = ritmRecord.variables["tracking_id"].getGlideObject().getValue();
}

Thanks

Ajit

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Ajit,

I have used this for global and scope

var ritm = new GlideRecord('sc_req_item');
ritm.get('request', 'e5317f3b07f401102011ff208c1ed063');

var variables = ritm.variables.getElements(); 
for (var i=0;i<variables.length;i++) { 
	var question = variables[i].getQuestion();
	var label = question.getLabel();
	var value = question.getDisplayValue();
	if(label != '' && value != ''){
		gs.info('  ' + label + " = " + value + "<br/>");
	}
} 

Output:

find_real_file.png

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Ajit,

I have used this for global and scope

var ritm = new GlideRecord('sc_req_item');
ritm.get('request', 'e5317f3b07f401102011ff208c1ed063');

var variables = ritm.variables.getElements(); 
for (var i=0;i<variables.length;i++) { 
	var question = variables[i].getQuestion();
	var label = question.getLabel();
	var value = question.getDisplayValue();
	if(label != '' && value != ''){
		gs.info('  ' + label + " = " + value + "<br/>");
	}
} 

Output:

find_real_file.png

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ajit
Tera Contributor

Thanks Ankur.

Ajit
Tera Contributor

Hi @Ankur Bawiskar ,

On this line, I am getting exception 

var question = variables[j].getQuestion();

 

{
    "error": {
        "message": "The undefined value has no properties.",
        "detail": "ConversionError: The undefined value has no properties. (sys_ws_operation.f1f3898edbffb300e90690b3db961966.operation_script; line 65)"
    },
    "status": "failure"
}
 
Thanks
Ajit

Hi,

are you having MRVS in your item?

possibly that might be giving you the issue. The script I shared needs to be tweaked for MRVS

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader