Toggle menu

Bulk Closing Cases

The closeResolvedCases utility end point closes cases based on the length of time they have spent at a particular status with no activity recorded against the case. It can perform a dry run of the close operation and send a report of the cases that were/could be closed to one or more recipients.

Configuration

Before using this tool you'll need to set up its configuration rules.

The rules for the close case utility should be placed in an end point at config.<environment>.closeResolvedCases.getConfig. There's an example that can be copied at config.example.closeResolvedCases.getConfig

It has the following structure:

function(params, credentials) {
    let config = {
        batchSize: 20,
        maximumRunTime: "PT10M",
        report: {
            to: [{
                name: "The support team",
                address: "[email protected]"
            }]
        },
        rules: [{
                caseType: "feedback",
                ignoreClosureRules: true,
                closeCriteria: [{
                    status: "*",
                    statusDuration: "P3W",
                    closureReason: "Automatic",
                    closureNotes: "Automatically closed",
                    sendClosureEmails: ["Case Owner"]
                }]
            },
            {
                caseType: "complaint",
                ignoreClosureRules: false,
                closeCriteria: [{
                    status: "On hold",
                    statusDuration: "P2W"
                },{
                    status: "With client",
                    statusDuration: "P1W"
                }]
            }
        ]
    };
    return config;
}

Where:

PropertyTypeDescription
batchSizeIntegerThe number of cases to process in a batch. We recommend between 20-50
maximumRuntimeString <ISO8601 duration>An ISO8601 duration string that sets how long the end point will continue to process the rules. If this time is exceeded the end point will complete processing the current batch and then terminate
report.toArray <Objects>An array of objects where each sets the name and email address of a recipient
rulesArray <Objects>An array of object rules where:
rules[n].caseTypeStringThis is the case type ID the rules will apply to
rules[n].ignoreClosureRulesBooleanIf set as true, the case will be force closed even if it has outstanding tasks
rules[n].closeCriteriaArray <Objects>An array of criteria to consider for this case type
rules[n].closeCriteria[n].statusStringThe case status to test. An asterisk "*" will test against any status
rules[n].closeCriteria[n].statusDurationString <ISO8601 duration>An ISO8601 duration string. Cases that have exceeded this time spent at the named status with no activity logged against them will be closed. The end point determines "activity" by looking for the timestamp of the last note added to the case, including system notes
rules[n].closeCriteria[n].closureReasonStringA close reason to record in the case history
rules[n].closeCriteria[n].closureNotesStringA close note to add to the case history
rules[n].closeCriteria[n].sendClosureEmailBooleanDefault: true. Whether or not emails will be set when a case is closed
rules[n].closeCriteria[n].sendClosureEmailsArray <Strings>

The emails that should be sent when this rule is met. This is an array of categories of user:

  • Internal - Emails will be sent to the current case manager or group (depending on the case configuration)
  • Case Owner - The person who raised the case will be sent an email
  • Subscriber - Anyone subscribed to the case will be sent an email

For example, to send an email to the person who raised the case and any subscribers, use ["Case Owner", "Subscriber"]. 

The emails themselves are those configured in the Case Management Emails, Templates and Tokens section of the case configuration. Any configuration will also be respected (ie even if you set this rule to send an email to the case manager, if the email template has been disabled in the case config, no email will be sent)

If the array is empty, no emails will be sent

In the examples above:

  • any feedback cases that have been inactive and spent more than three weeks at their current status (whatever that status is) would be closed
  • any complaint cases that have been inactive and either on hold for over two weeks or with client for one week would be closed

Running the End Point

The goss.CaseManagement.v1.core.utils.closeResolvedCases.closeResolvedCases end point can either be used manually or run on a schedule.

Dry Run

If you run the end point using the testing tab in iCM, set the dryRun parameters as true:

{
    "dryRun": true
}

This will email a report to the users named in the configuration without closing any cases. The email includes a list of the cases that would be closed and those that would fail to close (because they may have outstanding tasks etc).

Scheduling

When scheduling the end point, pass in the {"_async":{}} parameter:

Scheduled Close Case End Point

The end point would normally be set to run daily or weekly, depending on the number of cases you suspect may be dormant. Each time it runs it will check the rules set in your configuration end point and attempt to close any cases that meet the close criteria.

Last modified on 7 March 2025