Skip to main content
All CollectionsFAQ's
Adding Today's Date to a Summary Template
Adding Today's Date to a Summary Template

How do I add today's date to my summary template?

Kseniya Verenich avatar
Written by Kseniya Verenich
Updated over 9 months ago

Adding today’s date to a summary template can be easily accomplished using a custom script. The date will maintain the date of the last time the summary view had its data refreshed.

  1. Select the Field Selector chart type.

  2. Choose Custom Chart as the data source and select any table. The table will have no bearing as we are pulling today’s date from ServiceNow and not a table or field.

  3. In the custom script field, paste the script at the bottom of this article

  4. Click Save.

  5. On the chart options panel set the number of rows and the number of columns to 1.

  6. Open the select fields and choose any field, again we are not pulling data from a record or field but simply pulling the date from ServiceNow.

  7. Click Save.

Copy This Entire Script In the Custom Chart Field

To change the date format, the getByFormat on line 2 can be updated to ServiceNow recognized formats by updating the string in the getByFormat method.

The label can be updated on line 8. Simply replace the “As Of” next to “label” with any desired string.

// Beginning of code snippet

var date = new GlideDate();

date.getByFormat("dd-MM-yyyy");

var display = date.getDisplayValue();

var data = {

chartData: [

{

"label": "As Of",

"value": display,

"type": "string",

"tableInfo": "",

"recordInfo": "",

"query": {

"type": "default",

"query": ""

}

}

]

}

chartData = {

data: data,

options: options

};

// End of Code Snippet

Did this answer your question?