Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

conditional filter

arishsaifi9
Mega Contributor

1 . Create a filter where the Incident was created after the user’s hire date

2. create a filter to display incidents that were resolved more than 30 days ago.

2 REPLIES 2

Dr Atul G- LNG
Tera Patron

Hi @arishsaifi9 

 

Added sample

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

Ankur Bawiskar
Tera Patron

@arishsaifi9 

Responses inline:

1 . Create a filter where the Incident was created after the user’s hire date

-> for this you will require scripted report with filter condition as INC doesn't hold the Caller's Hire Date

create client callable script include i.e. classless one with sandbox enabled and return INC sysIds satisfying your condition

then in report filter condition give like this

Sys ID [IS ONE OF] javascript: getIncidents()

function getIncidents() {
    var callerId = gs.getUserID(); // Change to specific caller sys_id if needed
    var userGr = new GlideRecord('sys_user');
    if (userGr.get(callerId)) {
        var hireDate = userGr.getValue('u_hire_date'); // Adjust field name if different (e.g., hire_date)
        if (hireDate) {
            var incGr = new GlideRecord('incident');
            incGr.addQuery('caller_id', callerId);
            incGr.addQuery('sys_created_on', '>=', hireDate);
            incGr.query();
            var sysIds = [];
            while (incGr.next()) {
                sysIds.push(incGr.sys_id.toString());
            }
            return sysIds.toString();
        } else {
            return '';
        }
    }

}

55.png56.png

Configuring Script sandbox property 

2. create a filter to display incidents that were resolved more than 30 days ago. -> this is easy with this filter condition

55.png

I hope this will get you started.

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader