List of recipients in notification via workflow

KB15
Giga Guru

I think I have most of the components to have this work but i'm missing something.

I have workflow triggering an event to fire an notification. The event contains a parameter script to get a list of email addresses from a list of users from a list collector. I can generate the array no problem.

Create Event activity:

(function() {

var arrayEmail = [];

var gr = new GlideRecord('sc_req_item');

gr.addQuery('number', current.sys_id);

gr.query();

if (gr.next()) {

var arrayUtil = new ArrayUtil();

var list = gr.variables.proj_employee_remove_list.toString();

var arrayList = list.split('.');

l = arrayList.length;

for (var i=0; i<=l; i++) {

var ue = new GlideRecord('sys_user');

ue.addQuery('sys_id', 'IN', arrayList[i]);

ue.query();

while (ue.next()) {

arrayEmail += (ue.email + ',');

}}

return "arrayEmail";

}

}());

The problem is passing the email addresses to the notification. I have the parameter 1 selected in the notification. The event fires but returns the RITM that's associated with workflow. What else am i missing or doing incorrectly?

1 ACCEPTED SOLUTION

KB15
Giga Guru

Looks like I had an error with the first part of the query. It should have been a 'sys_id', current.sys_id


Second, the parameter needs to pass the sys_id of the users so the second half of the script was wholly unnecessary.


I'm not sure if the toString at the end is necessary since it's already in a string format but it didn't hurt.



Thanks for the suggestions!



(function() {



      var arrayEmail = [];



      var gr = new GlideRecord('sc_req_item');


      gr.addQuery('sys_id', current.sys_id);


      gr.query();



      if (gr.next()) {


              var arrayUtil = new ArrayUtil();


              var list = gr.insertvariablename.toString();


              var arrayList = list.split(',');


              l = arrayList.length;



          return arrayList.toString();


      }


View solution in original post

10 REPLIES 10

I'm not using eventQueue anywhere. I thought the parm1 would send that over to the notification.


If I were to use it, where would I add this?


I misread, sorry about that. Since this is a workflow 'Create Event' activity, you can ignore my comments about gs.eventQueue().



If you pull up one of the event log records in detail, what does it look like?


Shows Parm1 contains the RITM number. I'm not sure where it's getting that value.



find_real_file.png


I would suggest using the Run script activity and calling gs.eventQueue();


That should work fine.



Please mark this response as correct or helpful if it assisted you with your question.

KB15
Giga Guru

Looks like I had an error with the first part of the query. It should have been a 'sys_id', current.sys_id


Second, the parameter needs to pass the sys_id of the users so the second half of the script was wholly unnecessary.


I'm not sure if the toString at the end is necessary since it's already in a string format but it didn't hurt.



Thanks for the suggestions!



(function() {



      var arrayEmail = [];



      var gr = new GlideRecord('sc_req_item');


      gr.addQuery('sys_id', current.sys_id);


      gr.query();



      if (gr.next()) {


              var arrayUtil = new ArrayUtil();


              var list = gr.insertvariablename.toString();


              var arrayList = list.split(',');


              l = arrayList.length;



          return arrayList.toString();


      }