Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

HOW TO GET THE RITM VARIABLES VIA SCRIPT?

ASHLE CRAIG
Giga Contributor

I am working on a requirement to provide a list of servers on a portal page.

I have two question.

1. How do i query the variable for the appcat request item should be equal to ac.sysid. Which would return all requests opened for 'this appcat'.

2. I am having trouble with querying the request items variables to the cmdb group table. 

var user = gs.getUserID();

var ac = new GlideRecord(cmdb_ci_service_dashboard);

ac.addQuery('owned_by', user);

ac.query();

while(ac.next())

//find all patching automation requests opened for 'this appcat' (xactly)

{

  var ritm = new GlideRecord('sc_req_item');

  ritm.addQuery('varible_appcat', 612063dedb8dbf8091dd25894b96197a=ac.sys_id); 

  ritm.query();

//loop to get the list of servers 

while(ritm.next()){

  //How to get the CMDB groups (target machines) related to the request

}

find_real_file.png

1 ACCEPTED SOLUTION

JP - Kyndryl
Kilo Sage

Hi Ashle,

I am not good at scripting, but have you looked at this ?:  https://docs.servicenow.com/bundle/sandiego-application-development/page/script/server-scripting/concept/c_ScriptableServiceCatalogVariables.html

 

Regards.

JP

 

Regards,
JP

View solution in original post

2 REPLIES 2

JP - Kyndryl
Kilo Sage

Hi Ashle,

I am not good at scripting, but have you looked at this ?:  https://docs.servicenow.com/bundle/sandiego-application-development/page/script/server-scripting/concept/c_ScriptableServiceCatalogVariables.html

 

Regards.

JP

 

Regards,
JP

John Dahl
Kilo Sage

To get the value of a variable, you would call gr.variables.variable_name.

I'm not sure what this line is supposed to do:
ritm.addQuery('varible_appcat', 612063dedb8dbf8091dd25894b96197a=ac.sys_id);

A normal query structure would looke like:
ritm.addQuery( 'fieldName', value );

An encoded query would look like:
ritm.addEncodedQuery( 'fieldName=value' );