Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How To Create Dynamic Report Title In Dashboard?

Himanshi Kumraw
Tera Contributor

Hi All,

We are looking for a solution in Reports. Can we create a Dynamic title for the report in Dashboard? 
Like we want the title as the dynamic format - "some name, +month/date".
Any leads would be appreciated.

Thank you!

1 REPLY 1

JP - Kyndryl
Kilo Sage

Hi Himanshi,

Modify this script to get the final format you want:

 

Adding the Month and Year on the Report title:

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 == 😎

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();

 

 

Regards.

JP

Regards,
JP