- 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-04-2022 08:44 AM
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2022 08:52 AM
Actually there are 2 BR one in the RITM table and the one I posted in the SCTASK table
Regards