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

@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 - LNG
Tera Patron

HI @Frank Cheung 

 

You can via list view without code

AGLearnNGrow_0-1740410531772.png

or 

universal_requestISNOTEMPTY

Sandeep Rajput
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

@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.