child incident should go to Closed state

Manohararuna
Tera Contributor

Hello Everyone,

 

          I have one requirement, in incident form under Closer information there is  a fields -Resolution code and it's having the option Duplicate.

if i select Duplicate option after that Check box field visible automatically under Close information field 

if i select Check box after that Duplicate incident(reference field) field visible under Check field

if select any incident number in Duplicate incident field and click on save button of main incident then selected incident (in Duplicate incident reference field) should go to closed state without respect of state.

 

 

Thanks,

Manohararuna.

 

 

2 ACCEPTED SOLUTIONS

Voona Rohila
Kilo Patron
Kilo Patron

Hi @Manohararuna 

You can add it as a child incident to the main incident record and if you have state sync from parent to child then the related child incidents will be auto-updated along with parent incident.

 

 

For your requirement

1 . if i select Duplicate option after that Check box field visible automatically under Close information field 

       Add both checkbox and duplicate field below close information field from 'Form Layout or Form Designer'

 

2.if i select Check box after that Duplicate incident(reference field) field visible under Check field

       Write a UI policy on that table and add conditions as 'checkbox || is || true', check Onload to true, reverse if false to true.

       In UI Policy Actions tab, add the field 'duplicate' and make 'visible' true.

 

3.if select any incident number in Duplicate incident field and click on save button of main incident then selected incident (in Duplicate incident reference field) should go to closed state without respect of state.

     Write a BR on this table and trigger After update, add conditions( make sure you add 'duplicate || changes AND duplicate is not empty' AND Any other conditions you require)

   In the script part, use below 'getRefRecord' functionality and update the incident state.

var grInc = current.u_duplicate.getRefRecord(); //map the proper field name of duplicate here
if(grInc.isValidRecord()) { // << only perform operations on it if it's a valid record
        grInc.state = 6 // resolved state
        grInc.update();
}

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

View solution in original post

Ankur Bawiskar
Tera Patron
Tera Patron

@Manohararuna 

Points

1) you can create UI policy for that

Table: Incident

Condition: Checkbox field is true (checked)

UI Policy Actions: Show the Duplicate incident reference field

2) Business rule

a) After update

b) Condition

Resolution code is Duplicate
AND
Checkbox is checked
AND
Duplicate incident field is not empty

c) Script

(function executeRule(current, previous /*null when async*/) {
    // Check if the Duplicate incident field is filled
    if (current.u_duplicate_incident) {
        var dupIncident = new GlideRecord('incident');
        if (dupIncident.get(current.u_duplicate_incident)) {
            // Set the state to Closed (usually 7, but check your instance)
            dupIncident.state = 7; // 7 is the default value for 'Closed'
            dupIncident.update();
        }
    }
})(current, previous);

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

View solution in original post

8 REPLIES 8

Voona Rohila
Kilo Patron
Kilo Patron

Hi @Manohararuna 

You can add it as a child incident to the main incident record and if you have state sync from parent to child then the related child incidents will be auto-updated along with parent incident.

 

 

For your requirement

1 . if i select Duplicate option after that Check box field visible automatically under Close information field 

       Add both checkbox and duplicate field below close information field from 'Form Layout or Form Designer'

 

2.if i select Check box after that Duplicate incident(reference field) field visible under Check field

       Write a UI policy on that table and add conditions as 'checkbox || is || true', check Onload to true, reverse if false to true.

       In UI Policy Actions tab, add the field 'duplicate' and make 'visible' true.

 

3.if select any incident number in Duplicate incident field and click on save button of main incident then selected incident (in Duplicate incident reference field) should go to closed state without respect of state.

     Write a BR on this table and trigger After update, add conditions( make sure you add 'duplicate || changes AND duplicate is not empty' AND Any other conditions you require)

   In the script part, use below 'getRefRecord' functionality and update the incident state.

var grInc = current.u_duplicate.getRefRecord(); //map the proper field name of duplicate here
if(grInc.isValidRecord()) { // << only perform operations on it if it's a valid record
        grInc.state = 6 // resolved state
        grInc.update();
}

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

@Manohararuna

I had shared the same solution earlier than others.

It would be great if you could accept my solution acceptance too. Thanks for understanding!


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Ankur Bawiskar
Tera Patron
Tera Patron

@Manohararuna 

Points

1) you can create UI policy for that

Table: Incident

Condition: Checkbox field is true (checked)

UI Policy Actions: Show the Duplicate incident reference field

2) Business rule

a) After update

b) Condition

Resolution code is Duplicate
AND
Checkbox is checked
AND
Duplicate incident field is not empty

c) Script

(function executeRule(current, previous /*null when async*/) {
    // Check if the Duplicate incident field is filled
    if (current.u_duplicate_incident) {
        var dupIncident = new GlideRecord('incident');
        if (dupIncident.get(current.u_duplicate_incident)) {
            // Set the state to Closed (usually 7, but check your instance)
            dupIncident.state = 7; // 7 is the default value for 'Closed'
            dupIncident.update();
        }
    }
})(current, previous);

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

@Manohararuna 

Hope you are doing good.

Did my reply answer your question?

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