Export Set pre and post Script example required.

guptashalini041
Kilo Contributor

Hi,

Can anyone help me to get Export Set pre and post Script example.

Which type of task we can achieve in pre and post script. Please share some sample code to understand.

Thanks

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Shalini,

 

In scheduled data export Pre and Post script is used for performing any steps once the file is being placed in mid server location or the process starts.

 

Example for Post Script: Consider a scenario that servicenow has placed the file in mid server location and now you want to create a zip file with same name and add this file in that zip. You can achieve this using post script.

Write mid server script include which will pick latest file from that mid server location and create zip file. you need to send javascript probe to call the mid server script include which can be done in post export script.

 

Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Shalini,

 

In scheduled data export Pre and Post script is used for performing any steps once the file is being placed in mid server location or the process starts.

 

Example for Post Script: Consider a scenario that servicenow has placed the file in mid server location and now you want to create a zip file with same name and add this file in that zip. You can achieve this using post script.

Write mid server script include which will pick latest file from that mid server location and create zip file. you need to send javascript probe to call the mid server script include which can be done in post export script.

 

Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Thanks Ankur for your response.

Can you please share some sample code for pre and post script of data export.

Or can you please share the url where I can get the sample code in servicenow.

 

Thanks

Hi Shalini,

 

I don't have any URLs where you can see the sample code.

 

Regards

Ankur

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

I'm not sure that your Post Script example is correct. My understanding is that the Export Set scripts are JaveScript that runs Server Side. I don't beleive that you can access the file again via a post script once it has been exported to the MID Server subfolder.

I'd be keen to see an example of this if you have a sample script, but I don't believe it's possible.

To be able to execute anything else such as a zip compression or renaiming of the file I suspect you'd need to use orchestration or IntegrationHub.

You could execute a workflow from a post script that then executes a batch file or PowerShell script via a custom  Orchestration activity or custom spoke ... assuming you have the licencing for this of course.