How do I delete a record and its child entities using REST API?

You can delete a record and its child entities by using REST API and Schedule process.

Delete a record and its child entities

You can delete a record by setting the parent record to Inactive status. Use the Delete Child Entities of Inactive Party Records schedule process to delete all associated child entities of inactive parent records.

Here's how you can do it:
  1. Delete the parent record
  2. Use Delete Child Entities of Inactive Party Records schedule process

Delete parent record

To delete a record such as account, contact, household, hub person or hub organization, you need to set the status of the record to "Inactive". You can change the status of an account with the Delete action.

cURL Command

curl
      -u <username:password> \ -X DELETE
      https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/accounts/CDRM_262783

Delete child entities of inactive party records

When you delete parent record like account, contact, household, hub person or hub organization from the UI pages, web services, or file import, all child entities like contact points, relationships, address, source system references, and so on aren't deleted automatically.

You can use the Delete Child Entities of Inactive Party Records scheduled process to delete all associated child entities of inactive party records. Once deleted, it's recommended that you Purge Inactive Data. Purging inactive records helps helps you free space and comply with data protection regulations.

Retain child entities of inactive parent records

If you want to retain the child entities, then you must move the child entities to a different parent record before inactivating the parent record. Here's how you can do that:
  1. Create a resolution request using REST API
  2. Run Request Dispatch Job

Create a resolution request using REST API

To move the child entities to a different parent record you can create a resolution request by referencing the details of the duplicate parties that you wish to resolve. Depending on the details, you can create a request payload by,
  • Using the Party Number
  • Using the Party ID and Specifying the Master Record
  • Using the Source System Reference

Note:

When you create a Resolution Request, a duplicate resolution work item is also created which is processed by the Oracle Fusion Data Quality system.

Here's an example of how you can create a resolution request using the party number:

cURL Command

curl -u <username:password> \ -X POST -d
        @example_request_payload.json
        https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/resolutionRequests

Example of Request Body

The following example shows the contents of the request body in JSON format.

{
"RequestName": "API Merge Request 001",
"ResolutionType": "MERGE",
"DuplicateParty": [
    {"PartyNumber": "CDRM_3102" },
    {"PartyNumber": "CDRM_3109" }
  ]
}

Example of Response Body

The following example shows the contents of the response body in JSON format.

{
  "RequestId" : 300100177252448,
  "RequestNumber" : "300100177252448",
  "RequestName" : "API Merge Request 001",
  "ResolutionStatus" : "PENDING",
  "ResolutionStatusMessage" : null,
  "ResolutionType" : "MERGE",
  "CreationDate" : "2019-05-02T09:14:10+00:00",
  "CreatedBy" : "MDM_ADMIN_V1",
  "LastUpdateDate" : "2019-05-02T09:14:10.321+00:00",
  "LastUpdatedBy" : "MDM_ADMIN_V1",
  "DuplicateParty" : [ {
    "PartyId" : 300100011634984,
    "PartyType" : "ORGANIZATION",
    "PartyNumber" : "CDRM_3102",
    "PartyName" : "Pinnacle Corporation",
    "MasterFlag" : true,
    "SourceSystem" : null,
    "SourceSystemReferenceValue" : null,
    "links" : 
  }, {
    "PartyId" : 300100011635048,
    "PartyType" : "ORGANIZATION",
    "PartyNumber" : "CDRM_3109",
    "PartyName" : "Firesite Wallover",
    "MasterFlag" : false,
    "SourceSystem" : null,
    "SourceSystemReferenceValue" : null,
    "links" : ...
  } ],
  "links" : ...
}

For more information see Create a resolution request.

Run Request Dispatch Job

The Request Dispatch job is used to process duplicate resolution requests that are in Pending or Submitted status. See Run Request Dispatch Jobs for more details.