From 60c5b4fa5875f27f0a08fd3159f3b338c37d2b7f Mon Sep 17 00:00:00 2001 From: Mahesh Khatal <112764461+maheshkhatal27@users.noreply.github.com> Date: Thu, 24 Oct 2024 13:45:20 +0530 Subject: [PATCH 1/2] Create addAttachment.js This syntax macro is used to create and add a new attachment to a specific record. --- GlideSysAttachment/addAttachment.js | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 GlideSysAttachment/addAttachment.js diff --git a/GlideSysAttachment/addAttachment.js b/GlideSysAttachment/addAttachment.js new file mode 100644 index 0000000..a18122b --- /dev/null +++ b/GlideSysAttachment/addAttachment.js @@ -0,0 +1,4 @@ +var attachment = new GlideSysAttachment(); +//The syntax for write api is - , , , +var attachmentSysId = attachment.write(current, 'file_name.txt', 'text/plain', 'file contents'); +gs.info("Attachment Sys ID: " + attachmentSysId); From 5cf126e0e3b3baf2054e43d073a30e2e8df09cb9 Mon Sep 17 00:00:00 2001 From: Mahesh Khatal <112764461+maheshkhatal27@users.noreply.github.com> Date: Thu, 24 Oct 2024 13:57:17 +0530 Subject: [PATCH 2/2] 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. --- OutboundEmail Action/sendOutboundEmail.js | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 OutboundEmail Action/sendOutboundEmail.js diff --git a/OutboundEmail Action/sendOutboundEmail.js b/OutboundEmail Action/sendOutboundEmail.js new file mode 100644 index 0000000..f49cd3a --- /dev/null +++ b/OutboundEmail Action/sendOutboundEmail.js @@ -0,0 +1,8 @@ +var mail = new GlideEmailOutbound(); +mail.setReplyTo('testing@example.com'); +mail.setFrom('developer@example.com'); +mail.setSubject('ServiceNow Testing'); //setting the subject +mail.addAddress('cc', 'admin@example.com','John Snow'); //specify the address and name +mail.setBody('Hello world!');//sets the email body contents +//mail.addRecipient('hacktoberfest@example.com');//Undocumented in ServiceNow docs but works in global scope. +mail.save();//Triggeres the outbound notification