Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Copy Attachment from Flow Designer

Ben42
Tera Contributor

Hello Experts,

 

For a catalog item I have built a Flow and I am creating a 'contract' record as part of that flow. But, I want to copy attachment from RITM to contract record that is created. 

Going through community posts, I have used 'Look Up Attachment' and 'Look up attachment records' and 'copy attachment' below are three screenshots, But what should I select as 'source attachment record' in my last screenshot? 

 

How can this be achieved? 

 

Ben42_0-1677700756387.png

Ben42_1-1677700781844.png

 

Ben42_2-1677700827766.png

 

Thanks,

Ben.

1 REPLY 1

Faizeal Mohamed
Tera Guru

Hi,

 

For copy attachment please use the action “Copy Attachment” In flow 

 

 

Step1:

Trigger condition 

Trigger is “Created”

table is sys_attachment

in condition, table name is “sc_req_item”

and put the catalog item name if you want to run this flow for specific catalog.

 

Step2:

Add actions “Copy Attachment”

source attachment is drag the RITM record using pills from step 1

target record using the script:

var gr = new GlideRecord("contrac table");
gr.addEncodedQuery('parent='+ fd data.trigger.current.table_sys_id)// add the correct relationship parameter
gr.query () ;
if (gr.next ()){
return gr.sys id;
}

Target table is your contract table.

Please try this and let me know.