- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 07:59 AM
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:
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2022 08:58 PM
Hi
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2022 06:55 AM
Hello Ankur, yes it's a multi-row variable set, how can I make it work?
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2022 08:58 PM
Hi
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2022 11:07 AM
Thank you for all your support!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 08:24 AM
hello
i can see the arr.push(obj); which you might have used to store the variables in obj JSON.
CAN YOU SEND THAT PART HOW ARE CONSTRUCTING THE JSON MAY BE WE CAN HELP YOU AFTER SEEING IT ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 08:38 AM
Thank you Monith, I posted it
Regards