Announcing the Global SNUG Board of Directors. Learn more here

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
tiagomacul
Mega Sage
Mega Sage

Export file to a mid server

 

ImageDescription
 find_real_file.png 01. Navigate to  >> System Export Sets > Create Export Set
 find_real_file.png 02. Enter a name for this Export Set
 find_real_file.png03. What to export, for an example incident
 find_real_file.png

 04.Where to export to

An Export Target details the location on a MID Server that data will be exported to.

 

For Standard, for example example starts with: "C:\MIDServerInstall\agent\export\"

 

YES, IF "Mandatory - must be populated before SubmitHave you already defined an Export Target?"

NO, Select a mid server

 

 find_real_file.png

 05. Type the file path, an example  "/myDirectory/MyExport/"

find_real_file.png

find_real_file.png06. Click Submit
  
find_real_file.png

07. How to test?

after created, scroll down and click "Test export 20 records"

find_real_file.png

find_real_file.png08. waitting
find_real_file.png09. Click View export History
find_real_file.png 10. You'll see the logs
 find_real_file.png11. On the mid server the file is available
  
  

Alternatively you can use script, like said johnstettin, on his post "click here"

 

 

/* exportToMid - Function to export a *specific* attachment to a mid servers
*  export folder. 
*
*  Usage: exportToMid("my_file_to_export.pdf", "incident", "12345678910111213", "MIDSERVER001")
*
*  @param attachment_name {string} - Specific attachment file name
*  @param attached_table {string} - Table the file is attached
*  @param attached_record {sys_id} - SYS_ID of the record the file is attached
*  @param mid_name {string} - MID Server name
*  @return {null}
*/
function exportToMid(attachment_name, attached_table, attached_record, mid_name) {
	/** TODO: Add Error Control and validation **/
	
	// Create ECC attachment record used to send the file to the mid server
	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', ecc_att.sys_id);
	at.addQuery('file_name', attachment_name);
	at.query();
	at.next();


	// 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=\"' + ecc_att.sys_id + '\" order=\"0\" stream_relay_transfer_progress_interval=\"150\" type=\"AttachmentProgressTransformer\"/>' +
					'<stream_relay_sink path="\/' + 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();
}

 

image

Summarizing articles

Export Sets

Export - Determine maximum rows to export - glide.csv.export.limit'

glide.excel.max_cell

EXPORTING DATA WITH SYS IDS / KB0690876

 

Version history
Last update:
‎06-24-2021 12:06 PM
Updated by: