- 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 09:59 PM
Hi Patrick,
Can you print the value of mrvs? that would help knowing the json key
gs.info(producer.name_of_variable_in_variable_set);
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
03-30-2020 05:31 AM
Here's a simple script I got to mostly work in a mock-up. Since this is a MRVS, pushing the variable values to an array is simplified.
var emailArr = [];
var mrvs = producer.bkbmrvstxt; //internal name of your MRVS
emailArr = mrvs.v_email; //name of the variable in the MRVS
current.watch_list = emailArr.join(',');
In my instance nothing gets assigned to the watchlist as emailArr.join(',') doesn't seem to be working for some reason. I confirmed through infoMessages that there are values in emailArr[0] and emailArr[1] when I add 2 rows that are valid email addresses of active Users, but then nothing is on the watchlist on the new incident and an infoMessage on emailArr.join(',') returns 'undefined', so that's as far as I got last week.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2020 11:37 AM
Hi Brad,
yep I'm getting the same "undefined" from the "emailArr.join". hmmmm...so odd?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2020 08:39 PM
Hi Patrick,
Did you try to print the multi row variable set value in logs to check how the json looks like?
gs.info('MRVS is: ' + producer.variableName);
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
03-31-2020 08:47 AM
Hi Ankur, thanks for your help...Brad figured it out, check out his script.