How to add to email in the notification using flow custom action

Vinod S Patil
Tera Contributor

Hello Everyone

I have requirement to send a notification to the selected user on the catalog item.

catalog item has variable 'app manager'(type: reference).  To this user we need to send a notification.

using custom flow action in the flow, how to do it please suggest.

Below code using in the custom action of the flow for triggering the notification.


(function execute(inputs, outputs) {
// ... code ...
var scItem = new GlideRecord('sc_req_item');
scItem.addQuery('sys_id', inputs.ritm);
scItem.query();
if(scItem.next())
{
var appMgr = scItem.current.variables.getDisplayValue('app_manager_approval');
}
gs.eventQueue('KP.SC.C2C.Power5Installation', gr, current.appMgr.email);
})(inputs, outputs);




@Ankur Bawiskar 

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@Vinod S Patil 

why custom action required?

You can simply use "Send Email" flow action and set the recipient, subject, body etc?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Pranesh072
Mega Sage
Mega Sage

Use "Get Catalog variables" action to fetch the variable values and then use send email or trigger event action to trigger the notification in your flow 

Vinod S Patil
Tera Contributor

@Ankur Bawiskar @Pranesh072 

we are fetching data from different record from different table.  for this we need to use email script and notification.
we are not able to add notification and email script in send email for this we need to go for the custom action of the flow. where we need to get selected user email id and call the event through gs.eventQueue method


@Vinod S Patil 

got it

2 ways to handle

1) have notification created on RITM table and then in that have email script etc, then use "Send Notification" flow action and select your Notification

OR

2) use a flow variable to form the complete HTML body and you can use "Set Flow variable" flow logic and then use this flow variable to be set in Body of "Send Email" flow action

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader