Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Add multiple values to a string field

Monique2
Kilo Expert

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 

1 ACCEPTED SOLUTION

Alikutty A
Tera Sage

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);

View solution in original post

1 REPLY 1

Alikutty A
Tera Sage

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);