Compose email should attach the attachments of the corresponding record automatically.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 10:17 PM - edited 09-30-2024 10:19 PM
Hi Everyone,
I am trying with a requirement to add all the corresponding attachments of the record to the email draft while composing an email from Work space.
The following business rule script which runs with the following condition works in native UI but not in workspace.
Any idea to make this workable in workspace.
Table: sys_email
>> Conditions:
Before
Insert
Filter condition:
Target table | is | sc_task
Script :
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', current.target_record);
gr.query();
if (gr.next()) {
GlideSysAttachment.copy('sc_task', gr.table_sys_id, 'sys_email', current.sys_id);
}
Thanks !
Ramkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 10:36 PM
Hi @Ramkumar Thanga
The sys_email table behaves differently in Workspace compared to the native UI.
Try the below Script :-
var taskGr = new GlideRecord('sc_task');
if (taskGr.get(current.target_record)) {
var attachmentGr = new GlideRecord('sys_attachment');
attachmentGr.addQuery('table_sys_id', taskGr.sys_id);
attachmentGr.query();
while (attachmentGr.next()) {
GlideSysAttachment.copy('sc_task', taskGr.sys_id, 'sys_email', current.sys_id);
}
}
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 11:48 PM
Do I need to change the table where the business rule runs ? What should be the table ?
What should be the condition then.
Regards,
Ramkumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 11:53 PM
use the same condition as you have given earlier
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 12:48 AM
It doesn't works for me Ravi.
In workspace whenever I try to compose the email, it opens a record in this sys_email_draft table. So do I need to try with this sys_email_draft table.
Thanks
Ramkumar