0

I have been looking for an example of what @sfdcfox suggested for this thread https://salesforce.stackexchange.com/a/332678/133263

"The first subsequent would be a get, the second the delete call" using Composite API referencing a collection of ids from the first subrequest in the second delete subrequest and was not able to find any example unless I make 2 calls to Salesforce one for Get, manipulate the response to build a string of ids and then make another call for Delete.

The following is causing an error (obviously) - "Only Strings and primitive data types are allowed to be referenced from previous operations."

My challenge is that I would like to delete a collection of records by an external id using allOrNone, hopefully all as part of one composite request.

{
"allOrNone" : false,
    "compositeRequest":
    [
        {
            "method": "GET",
            "url": "/services/data/v58.0/query/?q=SELECT Id From Custom_Object__c WHERE external_id__c IN ('xxx1','xxx2')",
            "referenceId": "getRecords"
        },
    {
            "method": "DELETE",
            "url": "/services/data/v58.0/composite/sobjects?ids=@{getRecords}",
            "referenceId": "delRecords"
        }
    ]
}
1

1 Answer 1

-1

When you mark a field as External ID + Unique, you're allowed to do CRUD operations against the record using that external id.

DELETE /services/data/v58.0/sobjects/Custom_Object__c/a00000000000001AAA

DELETE /services/data/v58.0/sobjects/Custom_Object__c/external_id__c/xxx1

{
    "allOrNone" : false,
    "compositeRequest":
    [
        {
            "method": "DELETE",
            "url": "/services/data/v58.0/Custom_Object__c/external_id__c/xxx1",
            "referenceId": "delxxx1"
        },
        {
            "method": "DELETE",
            "url": "/services/data/v58.0/Custom_Object__c/external_id__c/xxx2",
            "referenceId": "delxxx2"
        }
    ]
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .