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

3 Answers 3

7

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 = '[email protected]';
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
3
  • 1
    Thanks for this @Gortonington :)
    – Obet
    Commented Feb 18, 2020 at 15:08
  • I can't use this to fetch DE across accounts
    – Abhishek
    Commented Jun 29, 2021 at 12:59
  • This should be included in SF documentation, there is a lack of use cases. Commented Sep 16, 2022 at 11:44
2

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.

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

3
  • 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
    Commented Feb 17, 2020 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
    Commented Feb 17, 2020 at 7:21
  • Those AMP functions are limited to 2000, SSJS retrieve to 2500 records. WSProxy is the solution in this case Commented Sep 16, 2022 at 11:45

You must log in to answer this question.

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