Email a list of subscribed users

Cirrus
Kilo Sage

Hi,

Hopefully this is just me being a scripting novice.

We require the ability to send bespoke notifications to users subscribed to particular service offerings, and have created a catalog item where the service manager can select the offering and compose the email. Upon submit, a create event activity in the workflow should query the subscription table for each occurrence of that offering, and get the subscribed users email to pass as parameter 1. However, its currently only generating 1 email with no recipients, where there should be 7. Can anyone advise what we are doing wrong please. Script as it stands currently:

 

(function() {
   
var serv = new GlideRecord('service_subscribe_sys_user');  
serv.addQuery('service_offering','40c3aeb0974f2550063c7e371153affb');
serv.query();

while(serv.next()){
serv.getValue('email')
var mail = serv.toString();
    return mail;
}
}());

 

6 REPLIES 6

Community Alums
Not applicable

But why using event here? Why not fire the notification directly from the workflow? 

Cirrus
Kilo Sage

No reason, other than we were trying to plagiarize another solution which used event, But would we not still have the issue in scripting the workflow notification to identify the 7 recipients? When I run your script in the Assignees advanced script in a workflow notification, it still returns the same, 1 email, no recipient.