How to export .txt file in Midserver folder

Neeta1
Tera Contributor

Hi Experts ,

 

Can someone pls share the steps -  how to export .txt file in Midserver ?

 

Thank you.

5 REPLIES 5

Sndeveloper Adm
Tera Guru

@Neeta1 

 

Please find the thread in the community.

https://www.servicenow.com/community/developer-articles/export-a-record-attachment-to-a-mid-server-s...

 

Mark my answer correct , if it helps you to solve the problem.

@Sndeveloper Adm 

Thanks for your response , however when I am trying to to create XML for ECC payload , as per the given thread I am getting incorrect format  error .

 

Could you please help  -

 

"

	// 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>';

AshishKM
Kilo Patron
Kilo Patron

Hi,

You can use "Export Sets" option to export any file to MID server path. However the OOTB TXT format option is not available to select but you can add the option for TXT ( .txt ) extension in file name.

 

Create a Export Definition ( What data to export )

Create a Export Target ( MID Server Name and Path configure )

Create a Export Sets ( configure the export definition & target here along with fileName & Format

 

AshishKMishra_0-1677278795355.png

 

Update the Client Script ( Set file name extn ) function "setFileExtn" for TXT fileName

 

AshishKMishra_1-1677279084491.png

 

Update the UI Policy ( Show Use Label

 

AshishKMishra_2-1677279195732.png

 

Once you update these objects, your instance will be ready to export any TXT file on MID server. Even though you are not updating the UI Policy, still export will trigger and copy the file with .txt extension.

 

I have updated all these setting in my PDI and its working perfectly fine.

Try it, let me know if any issue.

 

 

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Neeta1
Tera Contributor

Hi @AshishKM 

 

Thanks for your response.

 

However I have to create the custom .txt file to create a report 

( For the reference - 

https://www.servicenow.com/community/developer-forum/create-txt-file-in-sys-attachment-from-data-sto...

and I think I can not use the export definition and the solution which you have provided above?