Retrieve emails from member list user records in Flow Designer

MBarrott
Mega Sage

I'm building a flow for the Resource Plan module in SPM. Basically once a resource has been request I want to send out an email detailing the request. 

 

I also want the requested resources to be CC'd on the email. 

 

Now I can see the Data P*ll 'Members List' but what would be the optimal way to retrieve the email addressed of those listed users? 

1 REPLY 1

Ehab Pilloor
Mega Sage

Hi @MBarrott,

You can retrieve members list and use a script to extract all the resource's email addresses.

(function execute(inputs, outputs)){
var emailAddresses = [];
var memberGR = new GlideRecord('resource_members');
memberGR.addQuery('resource_plan', inputs.resource_plan_sys_id);
memberGR.query();
while (memberGR.next()){
              var userGR = new GlideRecord('sys_user');
              if (userGR.get(memberGR.member)){
                     emailAddresses.push(userGR.email); 
             }
   }
outputs.emails = emailAddresses.join(',')
})(inputs, outputs)

Then when using email notification, set the CC field to {{outputs.emails}} from the script output.

 

If you found my response helpful, please mark it as solution and helpful.

 

Thanks and Regards,

Ehab