Highlighted
Absent Member.. Absent Member..
Absent Member..
307 views

Scheduled CSV Export filename change

Jump to solution

Hi Experts 

I am running an script in scheduler record to export csv for some specefic date of every month.

If you refer below script i have set the export path as below

Existing Export Path:

var path = "c:\\example\\tickets.csv";

tickets are being exported , but now i have a requirement for change the filename of export to export date. For example tickets_07032016.csv

I tried to add below variables and set " var path ="c:\\example\\tickets'"+js+"'" 

var d = new XMLDate( new Date() );
var js = d.getSCDateTimeString()

Do have any idea how we can add js (date) in export filename ?

Below is complete working script for reference.

var tickets = new SCFile("probsummary");
var query = "number#\"IM1000\" and problem.status=\"Work In Progress\"";
var rc = tickets.doSelect(query);

if (rc == RC_SUCCESS)
{
	var layout = new SCFile("format");
	var rr = layout.doSelect("name=\"probsummary.qbe.g\"");
	var path = "c:\\example\\tickets.csv";
	var delim = "csv"; // $L.delim = ","
	var header = true;
	
	var rteCode = new SCDatum();
	var rteNames = new SCDatum();
	var rteValues = new SCDatum();
	
	rteNames.push("record");
	rteNames.push("name");
	rteNames.push("query");
	rteNames.push("string1");
	rteNames.push("boolean1");
	
	rteValues.push(tickets);
	rteValues.push(layout);
	rteValues.push(path);
	rteValues.push(delim);
	rteValues.push(header);
	
	system.functions.rtecall("callrad", rteCode, "us.dump.delimited", rteNames, rteValues, false);
}

 

Thanks,

Deepesh
0 Likes
1 Solution

Accepted Solutions
Highlighted
Super Contributor.
Super Contributor.

Re: Scheduled CSV Export filename change

Jump to solution

Hello,

I have tested using this JS and the result for the filename is "tickets 03-07-16 07-46-39.csv" like "tickets MM-DD-YY HH-MM-SS"

var jsdate = d.getSCDateTimeString();
jsdate = jsdate.replace(/\:/g,"-");
jsdate = jsdate.replace(/\//g,"-");

var path ="c:\\tickets "+ jsdate +".csv";

 

LPP

Global Support Delivery Software Support Expert

If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a KUDOS by clicking on the STAR at the bottom left of the post and show your appreciation.

View solution in original post

5 Replies
Highlighted
Super Contributor.
Super Contributor.

Re: Scheduled CSV Export filename change

Jump to solution

Hello,

I have tested using this JS and the result for the filename is "tickets 03-07-16 07-46-39.csv" like "tickets MM-DD-YY HH-MM-SS"

var jsdate = d.getSCDateTimeString();
jsdate = jsdate.replace(/\:/g,"-");
jsdate = jsdate.replace(/\//g,"-");

var path ="c:\\tickets "+ jsdate +".csv";

 

LPP

Global Support Delivery Software Support Expert

If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a KUDOS by clicking on the STAR at the bottom left of the post and show your appreciation.

View solution in original post

Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Scheduled CSV Export filename change

Jump to solution

Thanks PLP

it worked for me, thanks a lot.

I need one more help , in query i want to export record which was opened previous month.

var query = "problem.status=\"Work In Progress\"";

For example ..if i am exportig report in march month then report should have data for feb month, means Only incident opened in last month and status as WIP.

 

Thanks,

Deepesh
0 Likes
Highlighted
Super Contributor.
Super Contributor.

Re: Scheduled CSV Export filename change

Jump to solution

Hello,

Please try this code:

var actualdate = new Date();
var actualmonth = actualdate.getMonth()+1;
if (actualmonth==1){
var previousmonth = 12;
var previousyear = actualdate.getFullYear()-1;
var startdate = "'01/"+ previousmonth + "/" + previousyear + "'";
var enddate = "'01/" + actualmonth + "/" + actualdate.getFullYear() +"'";
}
else
{
var previousmonth = actualmonth-1;
var previousyear = actualdate.getFullYear();
if (previousmonth<10){
previousmonth = "0" + previousmonth;
}
if (actualmonth<10){
actualmonth = "0" + actualmonth;
}
var startdate = "'01/"+ previousmonth + "/" + previousyear + "'";
var enddate = "'01/" + actualmonth + "/" + actualdate.getFullYear() +"'";
}

var query = "flag=true and problem.status=\"Work In Progress\" and open.time>" + startdate + " and open.time<"+enddate;

 LPP

Global Support Delivery Software Support Expert

If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a KUDOS by clicking on the STAR at the bottom left of the post and show your appreciation.
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Scheduled CSV Export filename change

Jump to solution

Thanks LPP

However i am still testing the code, but in a first cut it worked. 

Thanks a lot.

 

 

Thanks,

Deepesh
0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Scheduled CSV Export filename change

Jump to solution

Dear PLP

I need one more help, id it possible to export file to some share drive and not to local server. i tried to put export shared path but i get below errors in service manager.

3232( 3708) 04/22/2016 10:11:12 RTE E unable to open connection (file.open.withoptions,connect)
3232( 3708) 04/22/2016 10:11:12 RAD E File \z:\TMP\2016-03_open_tickets.csv could not be opened.

3232( 3708) 04/22/2016 10:11:12 RAD E Unrecoverable error in application: us.dump.delimited on panel prompt

shared folder is accessible via server via windows explorer.

 

Thanks,

Deepesh
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.