0

I see in other threads, that it's not possible to delete individual records from Data Extension because, without a primary key, individual records couldn't be identified.

Question 1: Is this the Salesforce Restriction or general limitation of any database? I mean can't we delete the rows which match filter?

Question 2: I see that when we delete a contact from "All Contacts" in the marketing cloud, then the records get deleted from sendable data extensions even when there is no primary key set. How salesforce is doing this? If I manage to convert non-sendable data extension to sendable data extension without primary key set, can individual records be deleted?

Question 3: Using Java FuelSDK, I managed to retrieve DataExtensionRow having column "_customObjectKey" which is having unique integer value for each row. Does it mean that we can delete rows using this hidden column name "_customObjectKey"?

Question 4: Can we set primary key, when records are already filled? I observed it sometimes allowed, sometimes not from salesforce Dashboard.

Question 5: If cloning Data Extension is the only possible way, then is there any provision in Salesforce to ensure that transaction is atomic and mutually exclusive? I mean what would happen when two or more parties try to write at the same time?

Edit

Based on answer given below for Q1 and Q2, it says it is possible to delete data from data extension based on filter. I was trying to delete all records which matches particular e-mail address using fuelSDK-Java:-

ETClient etClient = getClient();
    // 1. Retrieve the data extension
    ETResponse<ETDataExtension> response = etClient.retrieve(ETDataExtension.class, "key=XXXX");
    ETDataExtension de = response.getObject();
    System.out.println("ETDataExtension retrieved : " + de.toString());
    // 2. Retrieve the rows with specified filter
    ETResponse<ETDataExtensionRow> rowETResponse = de.select("emailaddress="+email);
    // 3. Get rows id _customObjectKey
    System.out.println("etRowResponse : " + rowETResponse.toString());

    // 4. Delete that row
    ETResponse<ETDataExtensionRow> deleteResponse = de.delete(rowETResponse.getObjects());
    System.out.println("deleteResponse : " + deleteResponse.toString());

It successfully retrieves the rows. But it is giving error when trying to delete :

individualResults = [com.exacttarget.fuelsdk.ETResult[
    status = ERROR
    responseCode = Error
    responseMessage = Keys Not Found
    errorCode = 70000
]]

However when I used DE having primary key, then rows successfully deleted.

1 Answer 1

3

Question 1 and 2: Yes, you can delete records that match a certain filter using ssjs in a DE irrespective of primary key or being sendable. You need to consider the limitations of 2500 rows and customize the code to handle it. Sample Snippet below:

    var complexfilter = {
                LeftOperand:{
                    Property:filter1,
                    SimpleOperator:"LIKE",
                    Value:value
                },
                LogicalOperator:"AND",
                RightOperand:{
                    Property:filter2,
                    SimpleOperator:"LIKE",
                    Value:value2
        },
       LogicalOperator:"AND",
                RightOperand:{
                    Property:filter3,
                    SimpleOperator:"LIKE",
                    Value:value3
        }
     };
      Write(complexfilter);
var data = yourDE.Rows.Retrieve(complexfilter);
 
  
    //Deleting each row
   for (var i = 0;i <data.length; i++)
    {
       var output = data[i][filter2];
 Platform.Function.DeleteDE(DE,[filter2],[output]);
     
    
    }

Question 4:No, you can't set a primary key on a DE that already has records.

4
  • Can you provide fuelSDK example?
    – charlie
    Commented Nov 17, 2020 at 9:21
  • Haven't done it personally, but you could find something salesforce.stackexchange.com/questions/48700/… Commented Nov 17, 2020 at 9:23
  • Tried equivalent fuelSDK code, it says "Keys not found" for DE that doesn't have a primary key. Working fine when the primary key is set.
    – charlie
    Commented Nov 17, 2020 at 9:46
  • 2
    @charlie - fuelSDK runs off the API (mostly SOAP) which does not have the same capabilities that the SSJS functions have. This is not possible via SDK or API, and is only possible via SSJS. Commented Nov 18, 2020 at 15:23

You must log in to answer this question.

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