We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Reporting title to contain date

Not applicable

Is there a way in reporting that I can populate the title with the date it relates to.

For example on my breadcrumb trail I specify I want all tickets created last month. Is there a way I can get the month name and possibly the year populated either on the report title or in the scheduled report email message? 


1 ACCEPTED SOLUTION

There's not a simple shortcut unfortunately (the method SN has just gives you a month number), but it can be done with your own script include function to produce the month name.  Here are the steps...

1)  Navigate to 'System Definition -> Script Includes' and create a new record with the following settings...

Name: u_dateUtils

Client callable: True

Script:

var u_dateUtils = Class.create();
u_dateUtils.prototype = {
	initialize: function() {

	},
	
	getMonthYearName :function(){
		var gdt = new GlideDateTime();
		var year = gdt.getYearLocalTime();
		var month = gdt.getMonthLocalTime();
		var monthName = '';
		if (month == 0)
			monthName = 'December';
		else if (month == 1)
			monthName = 'January';
		else if (month == 2)
			monthName = 'February';
		else if (month == 3)
			monthName = 'March';
		else if (month == 4)
			monthName = 'April';
		else if (month == 5)
			monthName = 'May';
		else if (month == 6)
			monthName = 'June';
		else if (month == 7)
			monthName = 'July';
		else if (month == 8)
			monthName = 'August';
		else if (month == 9)
			monthName = 'September';
		else if (month == 10)
			monthName = 'October';
		else if (month == 11)
			monthName = 'November';
		
		return monthName + ' ' + year;		
	},
	
	type: 'u_dateUtils'
};

2)  Set the 'Subject' field of your scheduled report with the following line.  It will call your custom function and return the Month/Year text you're looking for.  Adjust as needed.

javascript: 'Report created: ' + new u_dateUtils().getMonthYearName();

View solution in original post

6 REPLIES 6

Not applicable

Hi Mark, you really helped me out with this one.

You couldnt give me some guidance on this could you?

 

https://community.servicenow.com/community?id=community_question&sys_id=1c805d74db742f48200f0b55ca961976

Jason Siegrist
Giga Guru

How does this work its way into the Report Title and not just the email subject line?