Send email notification from Runscript in workflow?

snuser09
Kilo Expert

I would like to send meail notifcation from the runscript(workflow). I wrote below code but doesnt seem like working. Should something be configured before doing that? how to send variables.

Basically I am doing SOPA call, when SOAP execution fails, I would liek to send an email with form varibales? 

Edit:added below screenshot

 find_real_file.png

Thnak You

12 REPLIES 12

sachin_namjoshi
Kilo Patron
Kilo Patron

You need to use gs.eventQueue() method from run script to send email notification.

 

https://developer.servicenow.com/app.do#!/lp/new_to_servicenow/app_store_learnv2_automatingapps_madrid_generating_events?v=madrid

 

Regards,

Sachin

Alikutty A
Tera Sage

You have not pasted any code? You can create a new event for your notification and call it from any server side scripts to trigger your notification.

asifnoor
Kilo Patron

Hi,

Trigger an event from workflow. And configure your notification to listen to that event.

Check this article which explains how to trigger notification using events.

https://community.servicenow.com/community?id=community_article&sys_id=81a40d6adb1b2300b1b102d5ca961...

Mark the comment as a correct answer and helpful if it helps.

I created event in workflow activity and email notification. Called it from code. It didnot work

Attaching: event,workflow and email notification

Code to call event

var response = sm.execute();
var status = response.getStatusCode();
if(status != '200'){
alert("cannot put ticket in pinnacle");
}
gs.eventQueue('sc_req_item.sendEmailToPinnacle',current);

 

 

Can anyone help why is it not working?