3

I just learned how to use WSProxy as an alternative to use in Salesforce Marketing cloud. The SF documentation provides retrieve data but is only limited in retrieving data extension schema and details.

var prox = new Script.Util.WSProxy();
var props = { QueryAllAccounts: true };
var cols = ["Name","CustomerKey","CategoryID","IsSendable"];
var filter = {
    Property: "CategoryID",
    SimpleOperator: "equals",
    Value: 101367
};
var opts = {
    BatchSize: 25
};
var data = prox.retrieve("DataExtension", cols, filter, opts, props);

Is there a retrieve functionality for data extension rows in WSProxy, something like:

var prox = new Script.Util.WSProxy();
var cols = ["Field1","Field2","Field3","Field4"];
var filter = {
    Property: "Field1",
    SimpleOperator: "equals",
    Value: 101367
};

var data = prox.retrieve("DataExtensionObject", cols, filter);
5

You should be able to accomplish this with the below snippet. You just need to adjust to fit your needs:

var prox = new Script.Util.WSProxy(); //creates proxy for SOAP call

var subKey = 'something@example.com';
var deCustKey = 'DataExtensionTest'; //your DE's CustomerKey / External Key

var cols = ["Field1","Field2","Field3","Field4"];
var filter = {
    Property: "Field1",
    SimpleOperator: "equals",
    Value: 101367
};

var desc = prox.retrieve("DataExtensionObject[" + deCustKey + "]", cols, filter); //executes the proxy call
2
  • 1
    Thanks for this @Gortonington :)
    – Obet
    Feb 18 '20 at 15:08
  • I can't use this to fetch DE across accounts
    – Abhishek
    Jun 29 '21 at 12:59
1

Why do you want to use WSproxy for this, when you can use both ampscript LookupRows and SSJS Rows.Retrieve. The advantage of WSproxy is indeed on more advanced operations, normally only supported in SOAP API

2
  • Hi Lukas. Thanks for answering by the way. Since I'm new with using WSProxy, Im still unware of what I can and can't do with it. But I have read this from an article. "WSProxy has many practical uses, particularly in landing pages and automation script activities. It can also be considered as an alternative to AMPscript API functions, as the object clearly provides efficiency gains, both in development and performance, while also maintaining interoperability with AMPscript through SetValue and GetValue SSJS functions."
    – Obet
    Feb 17 '20 at 7:13
  • I'm after the efficiency and performance. And also the code structure of the WSProxy is more readable and straight-forward for me.
    – Obet
    Feb 17 '20 at 7:21
1

SSJS is only able to retrieve 2500 rows, but with WSProxy the return json object has a "HasMoreRows" value that can be used as a workaround to retrieve the rest of the rows.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.