Change approval notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2024 08:39 PM
Hi all,
I need a help on below request.
Whenever the change request is sending for approval notification to the approver, then it must include attachments of that change request. Currently that notification is created on sys approval table and include attachments option is not working. Pls suggest.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2024 08:42 PM - edited 01-20-2024 08:44 PM
for this you will need to write a before business rule on the sysapproval_approver table. and then use the glidesysattachment to copy the attachment. on the notification itself you will need to check the include attachmnet box
heres a smaple script to get you started
var attachment = new GlideSysAttachment(); var incidentSysID = 'ab1b30031b04ec101363ff37dc4bcbfc'; var incGR = new GlideRecord('incident'); incGR.get(incidentSysID); var copiedAttachments = attachment.copy('incident', incidentSysID, 'problem', incGR.getValue('problem_id')); gs.info('Copied attachments: ' + copiedAttachments);
heres a link to the docs on glidesysattachment
Mark ✅Correct if this solves your issue and also mark 👍Helpful if you find my response helped in any way
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 04:32 AM
Hello @Vijaykumar K ,
To achieve the requirement of including attachments in the change approval notification in ServiceNow, you can follow the suggested approach of using a before business rule on the sysapproval_approver table and leveraging the GlideSysAttachment API and modify the script further as per your need.
(function executeRule(current, previous /*null when async*/) {
// Check if the record is a Change Request (modify this condition based on your actual table and field names)
if (current.table_name == 'change_request' && current.state == 'awaiting_approval') {
var attachment = new GlideSysAttachment();
var changeSysID = current.getValue('sys_id');
// Replace 'change_request' with your actual table name
var changeGR = new GlideRecord('change_request');
if (changeGR.get(changeSysID)) {
// Specify the target table and sys_id for the attachments (modify this based on your requirements)
var copiedAttachments = attachment.copy('change_request', changeSysID, 'incident', changeGR.getValue('incident_id'));
gs.info('Copied attachments: ' + copiedAttachments);
// Add additional logic for sending notifications with attachments (modify based on your notification settings)
}
}
})(current, previous);
Also please refer to the following well-explained and detailed resources that provide valuable insights to help you achieve your requirement:
- Adding attachments to Email
- Send an Email Notification with Associated Attachments
- Adding Physical attachment to Notification - Adding attachment to Outbound notification
Also you can refer this sort YouTube video as well Add Actual Attachments to #ServiceNow Sent Mail
Let me know your views on this and Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 08:26 PM
Hi @DanielCordick @Aniket Chavan thnks for your suggestion. Currently we are using email script in notification to send approval request so, is it possible to add the attachment on the same notification. End result would be a long with approval notification that mail has to contain attachment as well. Pls suggest...
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2024 09:30 PM
Hello @Vijaykumar K ,
Certainly, it is possible. I've provided some links below that contain a script which should be beneficial for your work. Feel free to explore these resources. If you require further assistance, please don't hesitate to reach out. Additionally, if you could share more details about your script, I'd be better equipped to offer specific guidance. Looking forward to helping you!
Let me know your views on this and Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket