How to use variable set variables in a payload for a Rest Message?

Jesus Nava
Tera Guru

Hello experts please I need your help, I have a catalog item that used regular variables, once the item ordered, a BR would execute to post a message via REST i, here is the piece of code and it is actually working:

find_real_file.png

as you see in the payload there is the "variables" that will fetch from the catalog item variables.

My issue here is that I modified the catalog item and instead of variables I used a variable set and it is not fetching the variables from the variable set, how can I add the variables from the variable set?

this is the current Outbound HTTP result:

{"Variables":"{\"Variables\":[{\"Requested For\":\"XXXXX\",\"Description\":\"Testing\",\"Reminder: please open a new case for this\":\"\"}]}","attachments":[{"Caller":"XXXXXX","Short Description":"Request Delivery","title":"SCTASK0000001","title_link":"https://mycompany.service-now.com/api/now/table/sc_task?sys_id=f99a926a87c5d51074c731dd3fbb3569"}],"text":"Request has been assigned to the group: ServiceDesk"}

As you see only 3 variables show Requested for, Description and Reminder. I'm missing the variables from the vatiable set I created, coyld you guide me on how to do it?

Thank you

1 ACCEPTED SOLUTION

Hi @Jesus Nava 

then you need to parse the json string and get the value

something like this

var ritmSysId = current.request_item;

var jsonString;
var gr = new GlideRecord("sc_req_item");
gr.addQuery("sys_id", ritmSysId);
gr.query();
if (gr.next()) {
   jsonString = gr.variables.variableSetName; // give MRVS variable set name here
}

var parser = JSON.parse(jsonString);

var variableValue = parser[0].variableName; // give name of variable within MRVS

Regards
Ankur

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

View solution in original post

11 REPLIES 11

@Jesus Nava you BR is on RITM table right is yes you need to pass current.sys_id instead of current .request_item

current.request_item can be used when BR is on catalog task table 

if its one RITM please try this 

var ritmSysId = current.sys_id;
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(ritmSysId);

 

Actually there are 2 BR one in the RITM table and the one I posted in the SCTASK table

Regards