Add attachment from Task to Change

JDickson
Kilo Expert

Hi all,

 

Is it possible to take attachments added to a Change_task and put them on the Change record itself? One of our workflow steps is to create a task for creating an estimate, as part of this it requires an attachment and then can be closed. I want that attached estimate to be added to the Change record itself once the task has been closed so that the customer can see it.

 

Kind Regards,

John

1 ACCEPTED SOLUTION

dvp
Mega Sage
Mega Sage

As your requirement is to copy attachment when the task is closed

Create a business rule on change_task with condition as state changes to closed

and use the following script

 

GlideSysAttachment.copy('change_task', current.sys_id, 'change_request', current.change_request);

View solution in original post

10 REPLIES 10

Ok,

I have tried this and it hasnt worked, the error here is my task query. I wanted to use short description of task = Review and Estimate.

I have added attachment of the workflow script and the stage in the workflow it is intended to run at.

Thanks

John

dvp
Mega Sage
Mega Sage

As your requirement is to copy attachment when the task is closed

Create a business rule on change_task with condition as state changes to closed

and use the following script

 

GlideSysAttachment.copy('change_task', current.sys_id, 'change_request', current.change_request);

Perfect this works for me and as it would never be removed im not too worried about that for now.

 

Thank you

hi DVP,

 

greetings !!!

 

thank you for your detailed explaination. I have small query:

 

-> How we remove the attachment from the task, after task is closed/completed. 

(Reason why i am asking because, there in un-necessary data in the instance, you may say this data as duplicate data)

 

With Regards,

amIT kumar

You can use deleteAttachment method  in GlideSysAttachment

Below link might be helpful

https://docs.servicenow.com/bundle/jakarta-application-development/page/app-store/dev_portal/API_reference/GlideSysAttachmentScoped/concept/c_GlideSysAttachmentScopedAPI.html