Copy attachment from one instance to different instance

Pradeepa B
Tera Contributor

Hi,

 

I need to copy attachment from one instance to different instance under table cmn_location.

Could you please help me on this requirement.

 

Thank you

5 REPLIES 5

G Ponsekar
Mega Guru

Hi @Pradeepa B ,

 

The recommended way to copy attachments from one ServiceNow instance to another is using the REST Attachment API. The process involves retrieving the attachment's metadata and content from the source instance and then uploading it to the target instance via a server-side script. 
This method is suitable for a one-time migration or a scheduled integration. 
 
High-level steps
  1. Source Instance: Create a script (e.g., a Fix Script or Scheduled Job) to find the attachments for cmn_location and use RESTMessageV2 to make API calls to the target instance.
  2. Target Instance: Ensure the REST API is set up and authenticated, and the user has permissions to write attachments.
  3. Authentication: Both instances must be authenticated with each other. Basic Authentication or OAuth is required. Basic Auth is simpler for one-time scripts.

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

 

Thanks, GP

Bhuvan
Kilo Patron

@Pradeepa B 

 

Go to sys_attachment table and filter by table name cmn_location. If you want to perform manual activity, you can export XML or export set and import it in target instance under same table sys_attachment.

 

Bhuvan_0-1757431344740.png

You can automate this via Flow or Export Set as well but if it is a one-off activity, manual steps would be the ideal way to do it.

 

If this helped to answer your query, please mark it helpful & accept the solution. 

 

Thanks,

Bhuvan

Ankur Bawiskar
Tera Patron
Tera Patron

@Pradeepa B 

so do you want to sync attachments between Location records in those 2 instances?

what's your actual business requirement?

Usually we don't have any files attached to Location record as it's part of Core data in the instance along with other core tables such as Group, User, Department, Cost Center etc

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