This article works like a charm .
One struggle we had is to check in MID Server where the file is located.
The way to validate the successful File Transfer
>> Go to Export >> folder which you have specified while transferring the file in script.
Note: - We were able to transfer both .pdf and .txt file type
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// Create ECC attachment record used to send the file to the mid server
var attachment_name = "Complete.txt"; <replace with your file name>
var mid_name = "MID_Server_SCG_BIC_DEV"; < replace with your MID server name>
//var ecc_att = new GlideRecord('ecc_agent_attachment');
//ecc_att.initialize();
//ecc_att.name = 'Export Set Attachment';
//ecc_att.short_description = 'exportToMid: ' + attachment_name;
//ecc_att.insert();
// Copy attachments (OOB Function copies all attachments)
//GlideSysAttachment.copy(attached_table,attached_record,'ecc_agent_attachment',ecc_att.sys_id);
// Get the SYS_ID of the exact attachment file to be exported and used in ECC Payload
var at = new GlideRecord('sys_attachment');
at.addQuery('table_name', 'ecc_agent_attachment');
at.addQuery('table_sys_id', <sys_id_of_ecc_agent_attachment_record>);
//at.addQuery('file_name', attachment_name);
at.query();
at.next();
//gs.info('>>>> PRINT SYS ID>>'+at.getUniqueValue());
var export_folder = 'vim/ivbarcode'; < replace with the file path that you wish to create>
// Create XML for ECC Payload
var xmlString = '<?xml version="1.0" encoding="UTF-8"?>' +
'<parameters>' +
'<parameter name=\"stream_relay_response_topic\" value=\"ExportSetResult\"/>' +
'<stream_relay_source attachment_sys_id=\"' + at.sys_id + '\" type=\"AttachmentSource\"/>' +
'<stream_relay_transform attachment.table_sys_id=\"' + "48279b7adb01a11050bea0bdd39619c3" + '\" order=\"0\" stream_relay_transfer_progress_interval=\"150\" type=\"AttachmentProgressTransformer\"/>' +
'<stream_relay_sink path="\/' + export_folder + '\/' + attachment_name + '" type=\"FileSink\"/>' +
'</parameters>';
// Create ECC Record
var eccQueue = new GlideRecord('ecc_queue');
eccQueue.initialize();
eccQueue.agent = 'mid.server.' + mid_name;
eccQueue.topic = 'StreamPipeline';
eccQueue.queue = 'output';
eccQueue.state = 'ready';
eccQueue.payload = xmlString;
eccQueue.insert();
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>