Need to upload 168 different attachments - 1 each to 168 different records

Arka Banerjee1
Tera Contributor

Hi Team,

 

I need to upload 168 attachments, 1 each across 168 different records. Can you please help with how I can upload all of these in bulk.

 

Please note that there's no attachment field in the records, so all would go to sys attachment table itself. 

 

Could you please help with how I can upload them.

 

@Ankur Bawiskar 

12 REPLIES 12

Ankur Bawiskar
Tera Patron

@Arka Banerjee1 

not possible directly to do this in bulk

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Dr Atul G- LNG
Tera Patron

Hi @Arka Banerjee1 

How is this possible? Where will the system store the attachment if there is no attachment field?

We need an attachment field to store the files. If you upload an attachment for one record, how will it be associated with all 168 different records? Will the same file be copied to all 168 records, or what is the expected behavior?

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

Hi Atul,

 

What I meant to say is that there's no custom attachment field in the records. The records have the OOB manage attachments icon at the top.

 

There are 168 records, and for each record, a different attachment needs to be attached - which signifies 168 different attachments, and each would need to go into different individual record. Could you please help with how I can upload these in bulk?

Hi @Arka Banerjee1 

 

Have a look: Try transform map

 

https://www.servicenow.com/community/itsm-forum/is-it-possible-to-send-attachment-through-transform-...

 

 

You should be knowing these details in order to work

1) the base64encoded data of the attachment

2) file name

3) content type

once you are sure these all data is present in excel you can use onAfter transform script so that it adds attachment to that record which got created/updated

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {


	// Add your code here
	var fileName = source.u_file_name;
	var fileContentType = source.u_content_type; // such as image/jpeg or application/pdf
	var fileData = source.u_base64_data;
	var sa = new GlideSysAttachment();
	sa.write(target, fileName, fileContentType, fileData);

})(source, map, log, target);
*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************