Want to copy attachment from ritm to a table in servicenow

Priyanka Chaud1
Tera Contributor

Hi I have a requirement where I have to copy attachment from catalog item to a particular table. We have a reference field for that table in the catalog item. @Ankur Bawiskar please help me in this

1 ACCEPTED SOLUTION

@Priyanka Chaud1 

this should work fine

1) after insert BR on sc_req_item

Condition: current.cat_item.name == 'Your Catalog Item Name Here'

Script:

Note: Ensure you give correct variable name of your variable which refers wm_task table

GlideSysAttachment.copy('sc_req_item', current.sys_id, current.variables.variableName.sys_class_name, current.variables.variableName);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

12 REPLIES 12

@Priyanka Chaud1 

you are having a variable on your catalog item or a dictionary field on RITM table?

you told you are using flow so I already shared links for that

If you want to do this via BR then do this

1) after insert BR on sc_req_item

Condition: current.cat_item.name == 'Your Catalog Item Name Here'

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar script will be same as i shared?

@Priyanka Chaud1 

you didn't answer my question

you are having a variable on your catalog item or a dictionary field on RITM table?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I am having a variable field work order task and its pointing to work order task table which is reference field and i want to copy attachment on that table only @Ankur Bawiskar . As u mentioned create after insert br on sc_req_item what will be the script??

@Priyanka Chaud1 

Sorry I think you are confused.

What do you mean by having a variable field?

is it a reference variable or is it a reference field?

If it's a reference field on RITM then how is it getting populated? without knowing this you cannot know which Work order task you should copy the file

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader