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.

tiagomacul
Giga Sage

Get last updated Date record using GlideAggregate

 

var aggIncident = new GlideAggregate('incident');
aggIncident.addAggregate('MAX', 'sys_created_on');
aggIncident.groupBy('priority');
aggIncident.query();

while(aggIncident.next()){


//get the first record, this should be the latest


dtLastUpdate = aggIncident.getAggregate('MAX','sys_created_on');


gs.log('number=' +aggIncident.number + ' pri ' + aggIncident.priority + ' dtLastUpdate ' + dtLastUpdate);

}

 

Sample results

*** Script: number= pri 1 dtLastUpdate 2020-01-20 12:32:05
*** Script: number= pri 2 dtLastUpdate 2020-01-20 12:31:29
*** Script: number= pri 3 dtLastUpdate 2020-02-13 13:49:40
*** Script: number= pri 4 dtLastUpdate 2020-01-20 12:30:40
*** Script: number= pri 5 dtLastUpdate 2020-06-10 19:16:17

 

image

Script summary

Scripts - Oficial Doc.

Discovery

Versões do ServiceNow

Como testar / debugar o seu script?

Create default filter for a related list

Comments
Priyanka22Yadav
Mega Guru

Why the number is not getting displayed.

Version history
Last update:
‎06-12-2020 01:20 PM
Updated by: