How to Create attachment with same sys_id

Harsha Reddy
Tera Contributor

Hi Community,

 

I am doing the integration with between the two servicenow instances for knowledge management, in this case if i add the any attachment on knowledge article body, the same content should reflect into the target instance, in this case attachment sys_id should be same in the both the instances. In this case how we can create attachment on target instance with the same sys_id in the source instance. Someone please help me on this.

 

Thanks in advance,

Harsha Reddy

11 REPLIES 11

Chaitanya naram
Kilo Sage

Hi @Harsha Reddy 

 

Please take the export of xmls of data related to attachments from these two tables.

 

1) go to sys_attachment table and find the record related to your knowledge article and take export of it.

 

Hint: sort it using table sysid field provided with value of your knowledge article sys id.

 

2) go to attachment documents table and find the records related to the attachment and take XML export of those.

 

Hint: you can search with attachment name in this table.

 

Then import the xmls of both tables into your target instance. This will fulfill your requirement.

 

 

 

Thanks & Regards | Chiranjeevi Chaitanya Naram
Kindly mark the answer Correct and Helpful if it helps to resolve your issue.

Hi @Chaitanya naram ,

 

Is there any api to export the attachment data and import into the target instance?

You can capture the updates in your update set using GlideUpdateManager2() api and then you commit in your target instance.

 

 

var rec = new GlideRecord('sys_number');

rec.get('973c8e8a9d022000da615b13b3a22f32');

//Push the record into the current update set  

var um = new GlideUpdateManager2();

um.saveRecord(rec);

 

Or use the Attachment API provided by servicenow

Thanks & Regards | Chiranjeevi Chaitanya Naram
Kindly mark the answer Correct and Helpful if it helps to resolve your issue.

If we are using the Attachment API then its creating the attahcment with different sys-id right