Toggle menu

copyCase

Creates a copy of an existing case with a new business key.

The case you'd like to copy can be open or closed. If the original case is already closed, the terminated process instance must still exist in the workflow engine as this is the source of the data for the copy (the default behaviour is for an iCM Scheduled Tasks to delete terminated processes that are over a year old).

Copies can be linked, and it's possible to close both the original and the copy as part of the copying process. Values from the original case can also be overridden.

Note that this function creates a "shallow" copy of a case. The copy only includes:

  • case type
  • stage
  • status
  • contact details
  • form fields from the original case and additional details form

It does not copy:

  • attachments
  • emails
  • history
  • appointments
  • tasks
  • subscribers
  • questions

The copy of the case starts a new workflow process instance with a new business key and a start date of the time the copy was made. As the copy is a new case, emails and notifications will be sent as if the case had been raised normally.

Namespace

goss.CaseManagement.v1.api.copyCase

Worker

serverlibrary

Parameters

PropertyTypeDescription
caseObject, requiredDetails of the original case
case.caseIdString, requiredThe business key of the case to copy
The following properties are all optional
case.closeObjectThis optional property will close the original case and terminate any outstanding tasks
case.close.closureReasonStringThe reason the case is being closed
case.close.closureNoteStringAn additional note that will be added to the case history and email that is sent to the person who raised the case
userObjectDetails of the user performing the copy. If not supplied the default system users credentials will be used
user.siteUserNameStringNote that usernames are the account usernames of the relevant website user, which will likely be a GUID
copiedCaseObjectThe properties in this object can override values from the case that is being copied
copiedCase.ownerUserNameStringThe username of the person who raised the case
copiedCase.caseTypeIdStringThe case type ID for the type of case to be created (this is generally the case name in lower case and is set as part of your case configuration)
copiedCase.caseSubTypeIdStringThe case subtype. This must exist in the case configuration
copiedCase.caseStageIdStringThe case stage. This must exist in the case configuration
copiedCase.caseStatusStringThe case status. This must exist in the case configuration. Only open, in progress and escalated statuses can be set (creating closed cases is described below)
copiedCase.caseManagerIdStringThe username of the case manager (ie the account username, which may be a GUID) the copied case should be assigned to. The case manager must be a member of the relevant case manager group in the case configuration. If not provided, or invalid, the case won't be assigned and will be claimable by anyone in the configured case manager group
copiedCase.languageStringThe language code of the case. Defaults to EN if not set
copiedCase.targetDateString (date-time)The target completion date for the case (the SLA) eg "2022-06-23T09:27:53Z". Must be in the future. If not set a new target SLA will be calculated from the time the copy is made using the SLA for the case type
copiedCase.contactObjectDetails of the person who raised the case
copiedCase.contact.nameStringTheir full name. Automatically mapped to form_NAME
copiedCase.contact.emailString (email)Their email address. Must be in a valid format. Automatically mapped to form_EMAIL
copiedCase.contact.phoneNumberStringTheir phone number. Automatically mapped to form_PHONENUMBER
copiedCase.contact.addressStringTheir address. Automatically mapped to form_ADDRESSTEXT
copiedCase.closeObjectIf supplied the case will be created then closed
copiedCase.close.closureReasonStringThe reason for the case being closed
copiedCase.close.closureNoteStringA note that will be added to the case history and the close case email that gets sent to the person who raised the case
copiedCase.formObjectThis object provides details that would otherwise be provided by a form submission that starts the case. If not supplied the details from the original case are used
copiedCase.form.startFormStringThe name of the form used to start the case. This form must exist
copiedCase.form.summaryFormStringThe name of a form to display summary/read-only views of the case. Defaults to the startForm if not set
linkCaseObjectIf set creates a link between the two cases
linkCase.linkTypeStringThe type of link to create. Links are defined in the relatedCaseLinks property of your Environment Configuration

Examples

See Case Management API for a full example call.

This first example shows the minimum that needs to be set to copy a case:

{
    "case": {
        "caseId": "6651-5379-9769-1525"
    }
}

This example shows the full parameter structure:

{
    "case": {
        "caseId": "7078-6032-7376-9241",
        "close": {
            "closureNote": "Abc",
            "closureReason": "Closed"
        }
    },
    "user": {
        "siteUserName": "TIMG"
    },
    "copiedCase": {
        "contact": {
            "phoneNumber": "01752123456",
            "name": "Bill",
            "address": "New address",
            "email": "support@gossinteractive.com"
        },
        "language": "CY",
        "targetDate": "2022-10-22T11:44:29Z",
        "caseStatus": "In progress",
        "form": {
            "startForm": "ALLOTMENTENQUIRIES",
            "summaryForm": "ALLOTMENTENQUIRIES"
        },
        "close": {
            "closureNote": "Abc",
            "closureReason": "Closed"
        },
        "caseSubTypeId": "inspection",
        "caseManagerId": "TIMG",
        "ownerUserName": "TIMTEST",
        "caseStageId": "Stage 1",
        "caseTypeId": "newtype"
    },
    "linkCase": {
        "linkType": "Parent Of/Child Of"
    }
}

Responses

Success

{
    "id": 133,
    "result": {
        "success": true,
        "warnings": [],
        "errors": [],
        "caseBusinessKey": "7843-2019-5614-1867"
    },
    "jsonrpc": "2.0"
}

Error Messages

  1. "Case links have not been enabled"
  2. "Link type {0} is not configured on this environment - Available types are ({1}}"
  3. "Could not retrieve case {0}"
  4. "Process {0} is not a case"
  5. "User {0} does not exist"
  6. "Could not write process variables to case {0} during force closure"
  7. "Could not terminate processes ({0}) during force closure"

Warning Messages

  1. "No link type provided using default {0}"
  2. "Could not load tasks from workflow"
  3. "Original case has already been closed"
  4. "Could not close case {0} using standard closure attempting to force the closure of the case"
Last modified on September 22, 2022

Share this page

Facebook icon Twitter icon email icon

Print

print icon