- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2022 08:11 AM
Hello! I am trying to send multiple e-mails getting a single String as a parameter from a form field.
I could make the code to get a single e-mail and send it through notifications and events, like this:
------------------------------------------------------------------------------------------
(function() {
gs.eventQueue('send_email', current, current.variables.email);
})();
------------------------------------------------------------------------------------------
I am making this through a Workflow inside ServiceNow, and the code above worked very well.
My current code (see below) is trying to split the incoming String from the field in a Array, trying to run this array inside a loop to deliver all e-mails, but this solution is not working:
------------------------------------------------------------------------------------------
var emailID = g_form.getValue('email');
var spl = emailID.split(',');
var len = spl.length;
for(var i=0; i<len;i++){
gs.eventQueue('send_email', current, spl[i]);
}
------------------------------------------------------------------------------------------
I don't know where is the problem of my code, if is in the g_form.getValue, or in the split function, or even in the For Loop.
I really appreciate some help, thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2022 02:07 PM
You are mixing client side (g_form) and server side (gs.eventQueue) code.
Rather use current.variables.email.toString() instead of g_form.getValue('email').
Note: Email notifications will take a comma separated list of emails anyways, the split is not really required.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2022 02:07 PM
You are mixing client side (g_form) and server side (gs.eventQueue) code.
Rather use current.variables.email.toString() instead of g_form.getValue('email').
Note: Email notifications will take a comma separated list of emails anyways, the split is not really required.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2022 04:48 AM
Thank you very much, your solution worked great for me and solved my problem.
Just to clarify a doubt, every Script present in Workflow is classified as a Server-side Script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2022 11:06 AM