The CreatorCon Call for Content is officially open! Get started here.

Report show the latest record

Jeff42
Tera Contributor

Hi all,

One employee have multiple records in the table(Voluntary Agreement to Work Extra Hours), but I would like to only show the latest one in report. Could anyone help on this.

Screenshot 2024-03-21 175026.png

Thank you

Best Regards,

2 REPLIES 2

Simran Gadodiya
Mega Sage

Hi @Jeff42 

Hope this helps you. please refer below mentioned document.

https://www.servicenow.com/community/platform-analytics-articles/how-to-create-a-report-that-shows-o...

 

If this helps you please accept the solution and mark it as helpful.

Thanks

 

Jeff42
Tera Contributor

Hi @Simran Gadodiya 

thank you for your link, but don't know why not work for me, below my script include:

var Voluntary_Agreement_Latest_Record = Class.create();
Voluntary_Agreement_Latest_Record.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
    getLatestRecord: function(){
        var EmployeeID;
        var gr = new GlideRecord("sn_hr_core_voluntary_agreement_to_work_extra_hours");
        gr.addActiveQuery();
        gr.setLimit(1);
        gr.orderByDesc('sys_created_on');
        gr.query();
        if(gr.next()){
            EmployeeID = gr.sys_id;
        }
        return EmployeeID;
    },

    type: 'Voluntary_Agreement_Latest_Record'
});