The CreatorCon Call for Content is officially open! Get started here.

How can I do a Bulk upload of attachments?

vkambham
Tera Expert

I need to migrate some change request data from another system. I have the change requests and their related attachment data ( CR, attachment name) in csv extracts. The attachments themselves are in a folder. I was planning to use import set to import the csv data but then I don't know how to handle the attachment files. What is the the best way to import these attachments and relate them to the change requests?

11 REPLIES 11

bernyalvarado
Mega Sage

Hi Venkatesh, there's a really cool trick to handle the attachment files and associate these with a record in ServiceNow



Through the agent "AttachmentCreator", the ecc_queue can process and associate an attachment to a given record within ServiceNow. The fields of the ecc_queue entry will need to be the following:



  agent = 'AttachmentCreator'


  topic = 'AttachmentCreator';


  name = 'file.csv:plain/text'; // this will be in the form fileName:ContentType


  source = 'table:sys_id'; //replace with the table and the sys_id of the record on which the attachment needs to be placed on


  payload = GlideStringUtil.base64Encode(fileContent); //replace the fileContent with the content of your file in a string format.



With this you now can load into ServiceNow a file on which in one column you have the fileName, in another one a key to the reference record where you want to do the insert and then in another column the text of the csvs and then perform a transform where the data goes into the ecc_queue and it's attached to each respective record.



Lets touch base and I can further help you with it!



Thanks,


Berny


I removed this function GlideStringUtil.base64Encode and copied the base 64 content to payload, then it worked fine.


Hi Berny,

 

I have a similar requirement. Could you please explain the steps to achieve it?

I definitely need your help bernyalvarado. Hope I can still find you avaialble...

Hi Berny,

I have the same requirement wherein user needs to migrate data alongwith attachment. Can we achieve this via transform maps?