Dashboards & Reports

Pravershi
Tera Contributor

Hello Community 

This is my First time here!

I want to make a report to get latest created record (single record which is created last on table).

I tried script include but its not working for Tokyo Release.

Please suggest me a solution.

 

 

Thank You

 

6 REPLIES 6

Jasmine Wadhwan
Tera Contributor

Hi Praveshi , 
Reports in ServiceNow are designed to display multiple records based on various filters and conditions. They are not suitable for displaying a single, specific record, such as the latest incident.
As a work around you can build a custom widget or a ui page to display this and style the page according to your needs
Here is a sample solution using ui page and script include. We have used glide ajax to fetch the data from the table. 

Hemanth M1
Giga Sage
Giga Sage

Hi @Pravershi  ,

 

Is your script include client callable??, if not create a client callble script include

ex: script include

HemanthM1_1-1692019852732.png

//script

var inc = new GlideRecord("incident");
        inc.addActiveQuery();
        inc.setLimmit(1);
        inc.orderByDesc("sys_created_on");
        inc.query();
        if (inc.next()) {
            return inc.getValue("number"); //return latest incident number
        }

Condition in the report: 

javascript: new latestRecord().fetchRecord()

 

HemanthM1_2-1692019965925.png

 

 

 

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

Hi  

@Hemanth M1  Thank You for your help , I am trying the same approach and its working in San Diego Release but not with Tokyo.
 
 

Hi @Pravershi ,

 

did you check if the script include works on the actual table???

ex: on the incident table number

 

and l would also verify if mu script include is triggering (call from client script to validate)

 

Unfortunately i don't have Tolyo version to verify however its working in Utha, it should work in Tokyo as well.

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025