Skip to content

Instantly share code, notes, and snippets.

@angrycider
Last active March 23, 2021 07:14
Show Gist options
  • Save angrycider/02e858fd013144e1bab3b422f7dad72e to your computer and use it in GitHub Desktop.
Save angrycider/02e858fd013144e1bab3b422f7dad72e to your computer and use it in GitHub Desktop.
5. Upsert row to a Data Extension
//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);
}
});
@syuraj
Copy link

syuraj commented Jul 19, 2019

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)
);

@SunMartekVentures
Copy link

SunMartekVentures commented Mar 23, 2021

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