sending an email from within a script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2018 06:30 AM
Hi Gurus,
I'm attempting to run a script that updates a table then sends an email after the update.
The update of the table works fine, however the sending of the email does not.
The lines in bold below do not appear to be working properly.
Can anyone tell me how to send an outbound email directly from a script?
Any info will be appreciated.
Thanks in advance!
var user = email.body.employee.toString();
var gr = new GlideRecord('sys_user');
gr.addQuery('email',user);
gr.query();
gs.log(gr.getRowCount());
if (gr.next())
{
gr.active = false;
gr.update();
email.setFrom("umassmeddev@service-now.com");
email.setReplyTo("robert.poschmann@umassmed.edu");
email.setSubject("This is the new subject line");
email.setBody("This is the new body");
}
- Labels:
-
Scripting and Coding
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2018 12:37 PM
This is not the event . The event name you opened from the log is not - Update User Test . In event log you should search for the event that you expect to fire. which is "Update User Test"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2018 01:08 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2018 02:13 PM
The event state is error , so the event is not processed . can you try with gs.eventQueue('Update User Test', current, '3a5754b64f0ade00cdf248f18110c7b7',null); ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2018 07:22 AM
Unfortunately this statement is not working...gs.eventQueue('Update User Test', current, '3a5754b64f0ade00cdf248f18110c7b7',null);
and neither is this one...gs.eventQueue('Update User Test', current, gs.getUserID() , gs.getUserName() );
and the state says 'error' , very vague, is there anyway to get more information about what is causing the error?
and do i need an event to trigger a notification, can i call the notification straight from the code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2018 07:51 AM