Skip to content

Commit 7eb9ad9

Browse files
Added two syntax macros for Adding attachment and sending outbound email notification through script. (#160)
* Create addAttachment.js This syntax macro is used to create and add a new attachment to a specific record. * Create sendOutboundEmail.js The GlideEmailOutbound api can be used to trigger notification through script in case required to trigger notifications. The 'addRecipient' method can work in global scope(it is undocumented in servicenow) instead one can use setReplyTo for scopped app. Tested the snipped on my pdi before making submission.
1 parent f0621dd commit 7eb9ad9

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
var attachment = new GlideSysAttachment();
2+
//The syntax for write api is - <GlideRecord record>, <String fileName>, <String contentType>, <String content>
3+
var attachmentSysId = attachment.write(current, 'file_name.txt', 'text/plain', 'file contents');
4+
gs.info("Attachment Sys ID: " + attachmentSysId);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var mail = new GlideEmailOutbound();
2+
mail.setReplyTo('testing@example.com');
3+
mail.setFrom('developer@example.com');
4+
mail.setSubject('ServiceNow Testing'); //setting the subject
5+
mail.addAddress('cc', 'admin@example.com','John Snow'); //specify the address and name
6+
mail.setBody('Hello world!');//sets the email body contents
7+
//mail.addRecipient('hacktoberfest@example.com');//Undocumented in ServiceNow docs but works in global scope.
8+
mail.save();//Triggeres the outbound notification

0 commit comments

Comments
 (0)