variable information not populating
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Hi All,
My requirement is i need to bring all the variable information that user selected into description field with comma seperated values. Ex. let us assume in a catalog item there is variable A , Variable B and variable C. while submitting the request user answered to variable A and Variable B. so in the sc_req_item description field i need to populate those values by seperating commas.
I used the following script but it does not works. Sp tell me the way to approach this using business rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Hello @suresh kaliappa ,
Your code is working in my PDI. I attached some screenshot please refer that .I used particular catalog item sys_id in my code , so that BR will run only for that Catalog item.
If this helps you then mark it as helpful and accept as solution.
Regards,
Aditya,
Technical Consultant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hello @suresh kaliappa ,
If my response helps you then mark it as helpful and accept as solution.
Regards,
Aditya,
Technical Consultant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
Hello @suresh kaliappa ,
Your solution is correct but quiet straightforward and not dynamic as it consider particular catalog item..
Instead of try this,
var escArr = [];
var grMtom = new GlideRecord('sc_item_option_mtom');
grMtom.addQuery('request_item', current.sys_id);
grMtom.query();
while (grMtom.next()) {
var grOpt = new GlideRecord('sc_item_option');
if (grOpt.get(grMtom.sc_item_option)) {
var label = grOpt.item_option_new.getDisplayValue(); // variable label
var value = grOpt.value; // user’s answer
if (value) {
escArr.push(label + '=' + value);
}
}
}
current.description = escArr.join(', ');
If you find this helpful mark as helpful..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Monday
it should work
Are you sure BR is configured correctly to trigger?
what debugging did you do from your side?
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
