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

Hello Ankur,

         Thanks for the solution but i want to show the active incident only in Duplicate incident reference  fields.

 

Thanks,

Manohararuna

Hi @Manohararuna 

 

You can add reference qualifier condition for that field,

open the field dictionary, under the 'reference specification tab', add 'active || is | true' in reference qualifier condition.

 


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 

for that you can use simple reference qualifier and add Active=true in that field

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

Shubham_Jain
Mega Sage

@Manohararuna 

 

1. UI Policy or Client Script for Dynamic Field Visibility

Use UI Policies or Client Scripts to control field visibility:

  • UI Policy 1

    • Condition: Resolution Code == "Duplicate"
    • Action: Show Checkbox field.
  • UI Policy 2

    • Condition: Checkbox == true
    • Action: Show Duplicate Incident reference field.

2. Business Rule to Close the Referenced Incident

Create a Business Rule on the Incident table that runs after update:

  • Condition:

    • current.resolution_code == "Duplicate"
    • current.checkbox_field == true
    • current.duplicate_incident_field is not empty
  • Script:

     
if (current.duplicate_incident_field) {
    var dupIncident = new GlideRecord('incident');
    if (dupIncident.get(current.duplicate_incident_field)) {
        dupIncident.state = 7; // Closed
        dupIncident.close_code = 'Closed/Resolved by Caller'; // or appropriate code
        dupIncident.update();
    }
}

 

Note: Ensure the user has permission to update the referenced incident. You might need to handle ACLs or impersonation if required.

 

 

✔️ If this solves your issue, please mark it as Correct.


✔️ If you found it helpful, please mark it as Helpful.



Shubham Jain