How to Restrict a Child incident not to be a parent incident to other

harinya
Tera Contributor

Hi 
Below is My Requirement,
Can some one please hep
When user tries to add parent for an incident, it needs to check parent incident entered by user is child incident(it should be a child to any incident) or not
If it's child Incident Then it should update the parent incident and provide a message "child incident can't be parent incident" and it abort the action
If it's not child incident to any incident then parent incident column should get updated with given incident and also update the assignment group same as parent incident that user entered


Thanks 

1 ACCEPTED SOLUTION

James-B
Kilo Sage

You could just amend the reference qualifier on the parent incident field to:

 

 

Snag_9971037.png

 

This would prevent users from being able to select any incident that already has a parent incident. This would also work at from a list. 

 

What you have asked for is possible but to make it work when the user selects the incident you would have to use a client script and a client callable script include. You could use a business rule to do the same thing but that wouldn't work until the user has submitted and could potentially waste the users time. 

View solution in original post

6 REPLIES 6

harinya
Tera Contributor

Thanks for Response


The above both solutions i tried but it's not working
please provide other solution
i have tried this script

(function executeRule(current, previous /*null when async*/ ) {
        // Check if the current incident has a parent incident
        var test = current.parent_incident;
        gs.log('incident' + test);
        if (test != '') {
            gs.addErrorMessage('this incident is child incident to other parent' + test.getDisplayValue());
            current.setAbortAction(true);
            gs.addInfoMessage('tested in if');
            return false;
        }
            else {
                gs.addInfoMessage('tested');
               current.assignment_group=parent_incident.assignment_group
                current.update();
            }

        })(current, previous);
it's not working
 

James-B
Kilo Sage

Both work just fine, however there is an issue with the reference qualifier I gave. The colon is being replaced with HTML code, I have replaced it with an image so it shows the correct code. 

 

Here is a working xml of the UI policy suggested by "Cris P" which I tested in my PDI.