Last active
March 23, 2021 07:14
-
-
Save angrycider/02e858fd013144e1bab3b422f7dad72e to your computer and use it in GitHub Desktop.
5. Upsert row to a Data Extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//UPSERT DE | |
var co = { | |
"CustomerKey": "7254CCBC-E5F8-49B6-991E-855825DAEADD", | |
"Keys":[ | |
{"Key":{"Name":"subscriberkey","Value":"test@fakeemail.com"}}], | |
"Properties":[ | |
{"Property":{"Name":"color","Value":"purple"}} | |
] | |
}; | |
var uo = { | |
SaveOptions: [{"SaveOption":{PropertyName:"DataExtensionObject",SaveAction:"UpdateAdd"}}] | |
}; | |
SoapClient.update('DataExtensionObject',co,uo, function(err, response){ | |
if(err){ | |
console.log(err); | |
} | |
else{ | |
console.log(response.body.Results); | |
} | |
}); |
I have tried both the original syntax as well as the updated version provided here and neither seem to work. Can you please provide an update on how to updateadd mutiple rows?
Here is what worked for me.
@jragsdaleSFDC
const updateValues = {
'Name': 'table_name',
'Keys': [
{ "Key": { 'Name': 'Key', 'Value': 'key_value' } }],
"Properties": {
"Property": [
{ 'Name': 'Key', 'Value': 'key_value' },
{ "Name": "ClientId", "Value": this.thCreds.ClientId },
{ "Name": "ClientSecret", "Value": this.thCreds.ClientSecret },
{ "Name": "WorkSpaceId", "Value": this.thCreds.WorkSpaceId },
{ "Name": "SiteKey", "Value": this.thCreds.SiteKey },
{ "Name": "BaseUrl", "Value": this.thCreds.BaseUrl }
]
}
};
const updateOptions = {
SaveOptions: [{ "SaveOption": { PropertyName: "DataExtensionObject", SaveAction: "UpdateAdd" } }]
};
this.SoapClient.update(
'DataExtensionObject',
updateValues,
updateOptions
this.soapRetrieveCallback.bind(this)
);
How can we upsert rows without primary key-value data extension?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This appears to be an incorrectly formatted object for constructing the desired XML when updating more than one property.
As expressed here, the
Properties
object, when updating two or more property values would intuitively be... which gets parsed into XML as ...
Notice that each property gets expressed in a sibling Properties node. When this is interpreted by the remote system, only the last value is processed. To have the intended multi-value update, you have to change the Object nesting pattern slightly so that the constructed XML places the sibling node relationship at the Property level.