- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2019 05:21 AM
In one of our workflows, we have a task and then an approval. I need help copying the attachment from the task to the approval so the attachment gets included in the approval email. Can anyone help me with the script?
Solved! Go to Solution.
- Labels:
-
Request Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2019 05:26 AM
It's pretty easy to copy an attachment, you just need the original attachment's table name ('sys_task' in your case) and the sys id for the task (these are the first 2 arguments below).
Then, the next 2 arguments are the table name and sys_id for the record you want to copy to:
new GlideSysAttachment().copy(originalAttachment.table_name, originalAttachment.table_sys_id, destinationTableName, destinationSysId);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2019 05:57 AM
I tried this on the approval activity
new GlideSysAttachment().copy("sc_task", "workflow.scratchpad.taskid", "sysapproval_approver", current.sys_id);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2019 06:48 AM
I ended up using a business rule
(function executeRule(current, previous /*null when async*/) {
var gr = new GlideRecord('sc_task');
gr.addEncodedQuery("request_item.cat_item=bda2c072db4ca7c0f28289584b961926^request_item="+current.sysapproval.sys_id);
gr.query();
while (gr.next()) {
gs.log(gr.sys_id);
var taskid= gr.sys_id;
new GlideSysAttachment().copy("sc_task", taskid, "sysapproval_approver", current.sys_id);
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2019 06:49 AM
You're passing in "workflow.scratchpad.taskid" which is a string, you probably want to do it without the quotes (workflow.scratchpad.taskid) so it will pass the actual task id in