Scheduled Data Export-customized csv file

Sagaya
Tera Expert

Hi ,

I need to export table records to MID server folder with csv format. So i am using Scheduled data export .

I have export definition & its fields, the export target, the mid server configured, the path configured, format as csv.

But the problem is , client need some fields based on logic and concatenate more than one column. So there is no one-to-one mapping in some fields.

Sample : 

In incident table ,  need to concatenate incident number & Category  and include this value in csv file [INC0000038_software]

Need to get the incident records based on some logic/dependent table value.

 

How can i address this issue ? because in "Export Definition" there is no script option to get the field value based on logic.

So can i follow the steps to address this issue?

1. Configure Scheduled data export with direct field values.

2. in "Scheduled data export" --> "Execute pre-export script" access the attached csv file and append the filed which need to populate based on logic.

 

Please share sample script for #2.

 

Regards,

Sagaya Rajan.

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@Sagaya 

I did something similar way back in 2017 but I had written mid server script include which uses Java packages + javascript to manipulate CSV

what I did was this

1) allow csv to get exported

2) then in post export script call the mid server script include

3) that mid server script include will use java code to read the csv file, perform manipulation and create fresh csv file as per client need and then delete the older csv

I believe you need to use the same logic since you cannot use Pre-export script since by that time the csv file itself is not ready.

One thing you can try is this

1) when the csv file is generated it gets attached to ecc_agent_attachment table

2) you can try to write some BR on sys_attachment with condition as table=ecc_agent_attachment and create fresh csv and attach again to same record

Check this blog

Scheduled/Export file/records to attachment to a mid server folder 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

Hi Ankur,

 

Thank you for your prompt response and help. Thank you.

 

Regards,

Sagaya.

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Sagaya 

I did something similar way back in 2017 but I had written mid server script include which uses Java packages + javascript to manipulate CSV

what I did was this

1) allow csv to get exported

2) then in post export script call the mid server script include

3) that mid server script include will use java code to read the csv file, perform manipulation and create fresh csv file as per client need and then delete the older csv

I believe you need to use the same logic since you cannot use Pre-export script since by that time the csv file itself is not ready.

One thing you can try is this

1) when the csv file is generated it gets attached to ecc_agent_attachment table

2) you can try to write some BR on sys_attachment with condition as table=ecc_agent_attachment and create fresh csv and attach again to same record

Check this blog

Scheduled/Export file/records to attachment to a mid server folder 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi Ankur,

 

Thank you for your prompt response and help. Thank you.

 

Regards,

Sagaya.