Use this action to clone a record and its related objects based on configuration. For example, you can instantly duplicate complex project templates including all predefined milestones and task dependencies.
Required Editions
| Available in: Lightning Experience |
| Available in: Enterprise, Unlimited, and Developer Editions |
Input Values
| Parameter | Description | Data Type |
|---|---|---|
| recordId | The ID of the record to clone. | String |
| objectApiName | The API name of the object to clone, such as Quote or Order. | String |
| objectDetailsInSortedOrder | A JSON string containing the configuration of objects to clone in sorted order. | String |
| executionMode | The mode of execution, either sync (synchronous) or async (asynchronous). The default is async. | String |
| targetRecordId | The ID of the existing record to use. If provided, the action uses this record instead of creating a new one. | String |
| targetRecordTypeApiName | The API name of the record type to set on the cloned record. | String |
| targetFieldUpdates | A JSON string containing field API names and values to update on the cloned record. For example: {"Name":"New Name","Status":"Draft"}. | String |
| runPricing | A Boolean value that indicates whether to run pricing after cloning. | String |
| runValidation | A Boolean value that indicates whether to run validation after cloning. | Boolean |
Note If the source quote or order's status is Activated, Salesforce won't let the cloned record save with that status. Include a Draft value in targetFieldUpdates (for example, {"Status": "Draft"}) for the clone to succeed.
Output Values
| Parameter | Description | Data Type |
|---|---|---|
| isSuccess | A Boolean value that indicates whether the clone operation was successful. | String |
| outputMessage | A message containing the details of the output. | String |
| clonedRecordId | The ID of the cloned record. | String |
| clonedRecordName | The name of the cloned record. | String |
| clonedRecordStatus | The status of the cloned record. | String |
| asyncJobId | The batch job ID if the execution mode is asynchronous. | String |
| errorMessage | An error message if the operation failed. | String |
Example
JSON Request
{
"recordId": "8013A000001XyZQAA0",
"executionMode": "sync",
"runPricing": false,
"runValidation": false,
"targetRecordId": null,
"targetRecordTypeDevName": null,
"targetFieldUpdatesJson": "{"Name": "Cloned Order - Copy", "Status": "Draft"}",
"objectDetailsInSortedOrderJson": "[
{
"className": "B2BCmexCloneImpl",
"dependentFields": [],
"filterFieldName": "Id",
"filterOnObject": "Order",
"objectName": "Order"
},
{
"className": "B2BCmexCloneImpl",
"dependentFields": ["vlocity_cmt__OrderId__c"],
"filterFieldName": "vlocity_cmt__OrderId__c",
"filterOnObject": "Order",
"objectName": "vlocity_cmt__OrderGroup__c"
},
{
"className": "B2BCmexCloneImpl",
"dependentFields": ["vlocity_cmt__OrderId__c", "vlocity_cmt__OrderGroupId__c"],
"filterFieldName": "vlocity_cmt__OrderId__c",
"filterOnObject": "Order",
"objectName": "vlocity_cmt__OrderMember__c"
},
{
"className": "B2BCmexOrderItemCloneImpl",
"dependentFields": ["OrderId", "vlocity_cmt__OrderGroupId__c", "vlocity_cmt__OrderMemberId__c"],
"filterFieldName": "OrderId",
"filterOnObject": "Order",
"objectName": "OrderItem",
"orderBy": "vlocity_cmt__LineNumber__c"
},
{
"className": "B2BCmexCloneImpl",
"dependentFields": ["vlocity_cmt__OrderId__c"],
"filterFieldName": "vlocity_cmt__OrderId__c",
"filterOnObject": "Order",
"objectName": "vlocity_cmt__OrderDiscount__c"
}
]"
}
JSON Response Body
{
"success": true,
"message": "Record cloned successfully",
"clonedRecordId": "8013A000002AbCDAA0",
"clonedRecordName": "Cloned Order - Copy",
"asyncJobId": null,
"error": null
}
JSON Response Body for Async Mode
{
"success": true,
"message": "Record cloned successfully",
"clonedRecordId": "8013A000002AbCDAA0",
"clonedRecordName": null,
"clonedRecordStatus": null,
"asyncJobId": "707XX0000004CuZQAU",
"error": null
}