Add a timestamp to a scheduled report

Not applicable

We have a few scheduled reports that are delivered to our service delivery manager daily, currently the subject / file name is the same everytime.

 

Is there a way to timestamp either the subject line or attachment file name?

1 ACCEPTED SOLUTION

CapaJC
ServiceNow Employee
ServiceNow Employee

When configuring a Scheduled Report, the Subject line now accepts JavaScript. e.g., the following in the Subject of a scheduled report will put the current date in the resultant email (e.g., for a report of today's problems):

javascript:"Problems created on " + gs.now();


View solution in original post

21 REPLIES 21

christine_passm
Kilo Explorer

I have been experimenting using the javascript function in the subject line of scheduled reports. This is great to find out how to do this!! (BTW it doesn't seem to work for Report titles, as asked by some others in this thread)

Does anyone know if there's any way to remove the time from the timestamp, and just leave the date?

Also, is there any way to show the date range?
eg. if your report is for last week, it would be great to show the date range of the week it's reflecting. Similar if you are reporting on incidents from last month, it could show the date range of the month.

thanks in advance,
Christine


This is possible for subject line. I have not figured out about renaming the attachment. I have many Date and Time Functions added to the out of box business rule called "Date Globals". I just add the function and call it when I need it. SN is now shying away from using BR and start using Script Includes, but have not had the time to convert them all.



Go to the BR called "Date Globals" and add this to the top or bottom of the script.



  function getYesterdayDateOnly() {


          var x=gs.daysAgo(1).split(' ');


          var y=x[0].split('-');


    var answer = y[1]+'-'+y[2]+'-'+y[0];


          return answer


    }



Now in your scheduled report, go to the subject and add this:     javascript:"Today's Report " + getYesterdayDateOnly();


Note: Add anything you want between the quotes.



When the report comes it subject will look like this: Today's Report 03-15-2014



Enjoy,


Dan Molnar


Jim Coyne
Kilo Patron

Take a look at this post to add the date/time stamp to the attachment(s) - Date/Time Stamping a Scheduled Report's Attachment(s)


So, I could not figure this out, so I reached out to Jim. As usual Jim is the MAN!



For some of you using the dynamic subject (adding date), you will quickly notice the subject only has a limited number of characters. Just use Jim's script and instead of "~!~rename_attachment~!~" use something like "~!~ren~!~". Just make sure it matches the business rule conditions and the current.subject.replace line 5. This is just a flag to find the email so use you imagination.


Malaya
Giga Expert

gs.now() works perfect but i am running into time zone issue after 7 pm. I am in central time zone and i noticed around 7 pm the date is showing as tomorrow's date. Any suggestions?