Show incident only when no parent UR

Frank Cheung
Tera Expert

hi,

i want to filter an incident out of a list if the incident has a parent universal request.

how do i do that in script?

many thanks.

 

1 ACCEPTED SOLUTION

Sandeep Rajput
Tera Patron
Tera Patron

@Frank Cheung 

var list = new GlideRecord("incident");
list.addEncodedQuery("universal_requestISEMPTY");
//list.setLimit(10);
list.query();
while (list.next()){
    gs.info(list.getDisplayValue());
}

View solution in original post

4 REPLIES 4

Dr Atul G- LNG
Tera Patron
Tera Patron

HI @Frank Cheung 

 

You can via list view without code

AGLearnNGrow_0-1740410531772.png

or 

universal_requestISNOTEMPTY

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

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/atul_grover_lng [ Connect for 1-1 Session]

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

Sandeep Rajput
Tera Patron
Tera Patron

@Frank Cheung 

var list = new GlideRecord("incident");
list.addEncodedQuery("universal_requestISEMPTY");
//list.setLimit(10);
list.query();
while (list.next()){
    gs.info(list.getDisplayValue());
}

Arymann Sinha
Tera Contributor

Hi @Frank Cheung ,
This gets you the incidents that don't have an parent incident with universal request.

 

 

var inc = new GlideRecord('incident');

// Query all incidents
inc.query();

while (inc.next()) {
    // Check if the incident has a parent
    if (inc.parent) {
        // Get the parent incident
       
        var parentInc = new GlideRecord('incident');
        parentInc.get(inc.parent);

        if (parentInc.universal_request) {
            gs.info("Incident " + inc.number + " has a parent incident (" + parentInc.number + ") with a universal_request.");
        }
    } else {
        gs.info("Incident " + inc.number + " "+inc.sys_id);
    }
}

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

@Frank Cheung 

this should be an easy task.

what's your challenge?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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