OBLYTECH Logo
OBLYTECH Logo

Close multiple incidents from a list with a UI action

To close multiple incidents from a list with a UI action, create a client-callable Script Include, a UI page that collects closure details, and a list choice named Close incidents. Agents select incident rows and run that action from Actions. The selected incidents receive the same resolution code and closure note.

Decide which incidents belong in one closure batch

This action suits a group whose closure can be explained accurately with one code and one note. Before selecting rows, compare the records rather than treating a filtered list as approval to close everything it contains. If two incidents need different explanations, put them in separate batches so the shared note remains meaningful.

The custom action writes state value 7 and supplies close_code and close_notes for the selected incident records. Review the incident states and lifecycle when deciding whether those records are ready for closure. A shared symptom alone is a weak reason to apply the same closure explanation.

For UI action configuration, use ui_action_admin or admin. The setup prerequisites identify business_rule_admin for business rule work; do not treat that as the UI action configuration role. Closing through this Actions list implementation does not require list_updater. Have an administrator review the complete configuration and test agent access before release.

The implementation uses GlideList2 and GlideModal, with List v2 Compatible selected on the UI action. Check its behavior on your instance and release, including the list interface agents actually use. For a workspace rollout, review the surrounding record pages, list pages, and side panel configuration before deciding where agents should perform this operation.

Build the server component that updates selected records

Start with the Script Include because the dialog needs a server endpoint to call. Navigate to All > System Definition > Script Includes and select New. Name the record IncidentClosure, select Client callable and Active, and save it after implementing the closure method.

The class extends AbstractAjaxProcessor. Its closeIncidents method reads three parameters: sysparm_incidents for the selected identifiers, sysparm_closeNote for the shared note, and sysparm_closeCode for the shared resolution code. Keep these parameter names aligned with the UI page client script; a mismatch can leave the server without the value the agent entered.

  1. Read the selected incident identifiers from sysparm_incidents.
  2. Create a GlideRecord query on incident, using sys_id with the IN operator and the selected identifier list.
  3. Iterate through the matching records.
  4. Set state to 7, close_notes to the supplied note, and close_code to the supplied code.
  5. Call update for each record and return true when the method finishes.

This flow explains the scope of the batch: the server query uses identifiers passed by the list action. During testing, preserve a record of the selected identifiers and compare them with the records changed. Do not infer correct selection merely because the list looks shorter after a refresh.

As an implementation review step, inspect server-side authorization and input validation before enabling the client-callable method for agents. The client dialog’s required fields and the UI action’s display condition should not be treated as proof that a direct request is authorized or complete.

Create the dialog for the common closure details

Navigate to All > System UI > UI Pages and select New. Use mandatory_fields_to_close_incident_ui as the name. The UI page contains the resolution fields and the client logic that connects the selected rows to IncidentClosure.

In the dialog HTML, provide a choice control labeled Resolution code and a text area labeled Resolution Notes. The code control uses closeCode as its identifier, and the notes area uses closeNotes. Include Cancel and OK controls connected to actionCancel and actionOK respectively.

Build the resolution choices deliberately. The example choices include Solved (Work Around), Solved (Permanently), Solved Remotely (Work Around), Solved Remotely (Permanently), Not Solved (Not Reproducible), Not Solved (Too Costly), and Closed/Resolved by Caller. Start the choice control at — None — so an agent must make a selection.

The page initialization clears the notes and disables OK. A change to the code control or input in the notes area reevaluates whether both values are nonempty. If either value is empty, OK remains disabled. Test both directions: entering valid details should enable submission, and clearing a value should disable it again.

In actionOK, retrieve the selected_incidents preference from the dialog. Use GlideAjax with IncidentClosure, set sysparm_name to closeIncidents, and pass the identifiers, code, and note through the three matching parameters. In the response callback, close the dialog and refresh the incident list through GlideList2. The Cancel handler destroys the dialog without calling the closure method.

Configure the UI action to close multiple incidents from a list

Navigate to System Definition > UI Actions and select New. Use the name Close incidents and the table Incident [incident]. This configuration places the action in the list workflow where agents can select several records before supplying the closure details.

  • Select Show update.
  • Select List choice.
  • Select List v2 Compatible.
  • Select Client.
  • Set Onclick to closeIncidents().
  • Use current.getValue(‘state’) !== ‘7’ as the Condition.

The client function obtains the incident list through GlideList2.get(‘incident’) and reads the checked identifiers with getChecked(). When identifiers are present, it creates a GlideModal for mandatory_fields_to_close_incident_ui. It sets the dialog title to Close Incidents, stores the identifiers in selected_incidents, and renders the dialog.

Keep the two closeIncidents functions conceptually separate during review. The UI action function gathers a selection and opens a dialog. The Script Include method receives a request and updates records. A working dialog does not establish that the server update path is correct.

For help planning this configuration, see ServiceNow implementation.

Review names across the three records before saving the final action. The modal name must match the UI page name, the preference written by the action must match the preference read by the page, and the Ajax class must match the Script Include. Keeping these connections visible in your change record makes a failed handoff easier to isolate.

Run a controlled closure test before agent use

Begin with a small group of test incidents that can legitimately share closure details, plus an unselected comparison record. Record their starting values. Select the intended rows and choose Close incidents from Actions on the Incident list. Supply the common resolution code and note, then select OK.

After the list refreshes, inspect the selected incidents individually. Check the stored state, resolution code, and notes against the intended result. Inspect the unselected comparison record as well. These checks distinguish a correct batch from a dialog that completed without updating the expected records.

Run a separate cancellation test and verify that the records retain their starting values. Also invoke the action with no rows checked: the client function opens its dialog when selected identifiers are present. Testing an empty selection helps reveal accidental changes to that guard during customization.

If the modal opens but records do not change, compare the UI page’s GlideAjax class name and method parameter with the Script Include. If the wrong records change, trace getChecked(), selected_incidents, and sysparm_incidents in order. If submission stays disabled, inspect the code and notes control identifiers and their event handlers.

Include a check of downstream behavior that matters to your operation. Where incident records feed other systems, use your incident management integration patterns to identify which connected outcomes need inspection. Treat that as a test plan for your configuration rather than an assumed result of the modal callback.

Keep the closure note specific enough to stand on its own inside an individual incident. Mention the outcome that justifies closure rather than referring vaguely to a batch or list. Read the proposed note against each selected record before submitting; a technically successful update can still leave an inaccurate incident history.

Questions about extending the batch closure action

Can this design give each incident a different note?

The request carries one note value for the selected identifier list. Supporting individual notes would require a different input and request design that associates each note with its incident. Prefer separate batches when the existing dialog is sufficient for the work.

Does the response provide a per-incident success report?

The server method returns true after its loop, and the callback closes the dialog and refreshes the list. It does not construct a result for each incident. If agents need that detail, design and test an explicit result report before relying on the action for reconciliation.

Is a maximum batch size defined by this configuration?

The configuration does not specify a maximum selection count. Establish an operating limit through controlled testing of your own records and update behavior. Avoid presenting an untested selection size as a supported capacity.

Should a closure batch replace a problem investigation?

Use the batch to apply an appropriate closure decision to incident records. Decide separately whether recurring issues need investigation through incident management versus problem management. Grouping incidents for an update does not itself explain why they occurred.