Need help on merging the selected incident records and making one has parent

Dhanalakshmi D
Tera Expert

Hi,

 

I need to create a UI action called merge incident and when users select 2 or 3 incidents with the same short desc the popup window should trigger seeking for the incident number which should be a parent and when the user selects the incident which should be a parent and then remaining selected records should be made as a child and copy the emails and attachments to the parent record. Can anyone guide me on how this can be achieved.

 

Thanks in Advance

5 REPLIES 5

OlaN
Giga Sage
Giga Sage

Hi,

There is already an OOB feature you can use, a field on the Incident table which can be set to indicate it's a child incident to another incident.

So the easiest way to use this, is to show that field "Parent Incident" on the list view, and then from the list view multi select records that should be connected to a specific parent incident record.

Optionally you can create a Flow or business rule, that runs on after setting the parent incident field, and copies attachments from the child records to the parent.

Personally, I prefer not to copy attachments, since it creates duplicates of data, which might be unnecessary.

douggriffin
Tera Contributor

What is the purpose of adding a duplicate Incident as a child to the Incident it duplicates, from the same caller?>

Dhanalakshmi D
Tera Expert

Hi OlaN,

 

This we need to implement even for the call table so I need new UI action.

 

Thanks,

Sohithanjan G
Kilo Sage
Kilo Sage

Hi @Dhanalakshmi D ,

 

Yes, you can have an UI action on list view, below the sample... 

(function executeMergeIncident() {

    // Check if at least 2 incidents are selected
    var selectedIncidents = g_list.getChecked();
    if (selectedIncidents.length < 2) {
        alert('Please select at least 2 incidents to merge.');
        return;
    }

    // Get the short description of the first selected incident
    var shortDesc = '';
    var parentIncidentSysId = '';

    // Iterate through selected incidents
    for (var i = 0; i < selectedIncidents.length; i++) {
        var sysId = selectedIncidents[i];

        var gr = new GlideRecord('incident');
        if (gr.get(sysId)) {
            // Check if short description is empty or matches the first incident
            if (shortDesc === '' || gr.getValue('short_description') === shortDesc) {
                shortDesc = gr.getValue('short_description');

                // Set the first incident as the parent
                if (parentIncidentSysId === '') {
                    parentIncidentSysId = sysId;
                } else {
                    // Make the current incident a child of the parent
                    gr.setValue('parent', parentIncidentSysId);
                    gr.update();
                }
            } else {
                alert('Selected incidents do not have the same short description.');
                return;
            }
        }
    }
})();

 

Configure the UI action:

  • Name: Merge Incidents
  • Table: Incident (or the table where you want to apply this)
  • Action name: merge_incidents
  • Client: true
  • Show Insert: false
  • Show Update: true

 

Please mark as Accepted Solution & HIT helpful if it suffice your requirement. 


BR, Sohith



Please mark as Accepted Solution if this solves your query and HIT Helpful if you find my answer helped you. This will help other community mates too..:)