- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2020 01:33 PM
Hi all,
this should be easy I would think, but something isn't working. I have a record producer with a mult-row variable set with one variable (single line text) for capturing email addresses to be added to the incident's Watch List when the record producer is submitted.
How do I access the values in the multi-row variable set to populate the Watch List? In the RP script i'm going with:
current.watch_list = producer.name_of_variable_in_variable_set; //variable in the variable set
Guessing there must be more to it?
thanks!
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2020 07:14 AM
Hi Patrick,
I had some more time to fiddle with this and got it to work with the below. There's something about the record producer script vs an RITM workflow script that is making the shortcut not work somehow - even though the array seems to be created correctly.
var emailArr = [];
var mrvs = producer.bkbmrvstxt; //internal name of your MRVS
for(var i=0;i<mrvs.v_email.length;i++){ //name of the variable in the MRVS
emailArr.push(mrvs.v_email[i]);
}
current.watch_list = emailArr.join(',');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2020 07:29 AM
See this article for some things I have been able to do to get the values from a MRVS. RP scripts behave like server scripts, so this should be on the easier side.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2020 11:43 AM
Thanks Brad, I'll check it out. I would think this would be easy...just need to find the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2020 07:40 AM
Hi Patrick,
you can get the value; parse it and then set the value in watch_list
I assume your json looks like this:
[
{
"email": "amy.jone@example.com"
},
{
"email": "abel.tuter@example.com"
}
]
Script for this: ensure you add the proper json key and the variable name
var str = producer.name_of_variable_in_variable_set;
var parser = JSON.parse(str);
var length = parser.length;
var emailArray = [];
for(var i=0;i<length;i++){
emailArray.push(parser[i].email.toString());
}
current.watch_list = emailArray.join(',');
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
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
03-27-2020 11:38 AM
Hi Ankur,
thanks for the response. How do I add the proper JSON key?