Change name of the file in export set

ark6
Mega Guru

Hi,

I am using export set and want to change the name of the file to be exported to mid server before exporting.

My requirement is to attach the current date to the file name, but when I do an append timestamp it appends both date and time on the file name.

Is there a way we can control this behavior and try to attach the date instead of a whole timestamp?

Regards,

Ark

18 REPLIES 18

Hi Ankur,



Thanks for reaching out. I already marked your reply as helpful



Regards,


Ark


Hi Ankur,



Thank you for sharing such valuable information, It is always intriguing to find out new capabilities in Service-Now Love It !!!



I have tried the Business rule on the sys_attachment table but it is throwing an error "No sensors defined". Should i also write a sensor code?



Please Advice.


pK.


Hi @Ankur Bawiskar ,

 The pre-script is not updating the  file name in Export Set before the export starts.

Now what is the solution ? How Can i fix this issue ? kindly help me.

Pre-script :

var Date = new GlideDate();
var todayDate = Date.getByFormat('yyyyMMdd');
var exportsetId = gs.getProperty('exportserID'); //ExportSet sysID
var filename = gs.getProperty('filename'); // FileName
var exportset = new GlideRecord('sys_export_set');
if(exportset.get(exportsetId ))
{
var modifiedName = filename+'_'+todayDate+.'csv';
exportset.file_name = modifiedName ;
exportset.update();
}

 

Post-script:
var prob =SncProbe.get("windows - Powershell");
prob.setName("windows - Powershell");
..
..

Hi,

are you sure the query ran fine?

Regards
Ankur

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

kaltrinekabashi
Kilo Contributor

Hi Arka, I have same requirements.



What I did is :


- Leave Append timestamp unchecked


- Allow user to add yyyyMMdd, ddMMyyyy, yyMMdd, ddMMyy, dd-MM-yyyy, yyyy-MM-dd to the Name of the Export Definition


- Change Dictionnary of File Name in Export Set record to a calculated value. Within a Script include, I replace the found regular expression by today's date on expected format.



One problem is still remaining: This way of doing only updates the file name whenever I open the export set record before the export is done. I am trying to figure out why is it behaving like this (it seems that calculated field is not recalculated when read is done on server side).