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 value of the variable in request item

ma kaiyue
Giga Guru

How can I get the value of the variable in the multi-row in the variable set in request item, I used

variables.<variables set name>

but there is an error like this.

makaiyue_0-1717036812262.png

 

Thanks in advance!

5 REPLIES 5

I have tried the below in background script:

 

var itemID = '376adcdc1baa8a905c8bea88b04bcb3f'; //sysID of RITM
var ritmGR = new GlideRecord('sc_req_item'); 
//You have to add your query according to your requirement
if (ritmGR.get(itemID)) {

var mrvsData = ritmGR.variables.service_agent_amendment.toString(); //Accessing the mrvs
var typeVariable =  ritmGR.variables.project_name; //accessing the variable of the catalog item

var mrvsVal = JSON.parse(mrvsData);
for (var i = 0; i < mrvsVal.length; i++) {
var var1 = mrvsVal[i].saa_project_name; //access the mrvs variable 1
var var2 = mrvsVal[i].service_agent_type; //access the mrvs variable 2
}
}

if(typeVariable == var2){
//Match found, return accordingly
    gs.info('Test');
}
----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.