- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2019 11:37 PM
Hi,
I have a workflow script that searches the user table and returns email addresses. I need to enter all the answers (',') into a string field, what currently happens is the last email address overwrites the previous email address.
Workflow script:
var user = new GlideRecord('sys_user');
var userlist = current.variables.daily_summary.getDisplayValue().toString();
user.addQuery('name','IN',userlist);
user.query();
emails = [];
while(user.next()){
emails = user.email;
current.variables.daily_summary_distribution_list_emails = emails; // This line overwrites the users email address.
}
Any assistance would be greatly appreciated.
Thanks
Monique
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2019 11:55 PM
Hi,
Please try this out
var user = new GlideRecord('sys_user');
var userlist = current.variables.daily_summary.getDisplayValue().toString();
user.addQuery('name','IN',userlist);
user.query();
var emails = '';
while(user.next()){
emails += ',' + user.email;
}
current.variables.daily_summary_distribution_list_emails = emails.substring(1);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-30-2019 11:55 PM
Hi,
Please try this out
var user = new GlideRecord('sys_user');
var userlist = current.variables.daily_summary.getDisplayValue().toString();
user.addQuery('name','IN',userlist);
user.query();
var emails = '';
while(user.next()){
emails += ',' + user.email;
}
current.variables.daily_summary_distribution_list_emails = emails.substring(1);