is it possible to send attachment through transform map?

jobin1
Tera Expert

Hi All

My requirement is business will be encoding the attachment and sending that encoded value in excel format and the same we need to decode and transfer to ritm form via transform map.

So is it possible to do so? if yes how?. what transform script we need to use to achieve this functionality 

1 ACCEPTED SOLUTION

Hi,

So you can use this in global scope

(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 ecc = new GlideRecord('ecc_queue');
	ecc.initialize();
	ecc.agent = "AttachmentCreator";
	ecc.topic = "AttachmentCreator";
	ecc.name = fileName + ":" + fileContentType;
	ecc.source = target.sys_class_name + ":" + target.sys_id;
	ecc.payload = fileData;
	ecc.insert();

})(source, map, log, target);

Regards
Ankur

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

View solution in original post

32 REPLIES 32

@Ankur Bawiskar 

Attaching the script is this is fine?

I hope you have given correct field names for the import set.

If yes then it should work fine and attach file with that file name to the target record

Regards
Ankur

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

@Ankur Bawiskar 

 

That is my query since we are not using filed map then how u_file_name is defining?
Also this file name should be  base64encoded data of the attachment right?

source.u_file_name;

 

 

 

find_real_file.png

Hi,

what does the excel contain?

Unless you have these details in the excel which I mentioned it won't work

1) the base64encoded data of the attachment

2) file name

3) content type

Regards
Ankur

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

@Ankur Bawiskar  Thankyou so much you are right. Now it got attached.