I'm using WSProxy to retrieve information about an Automation. This works fine, until I want to retrieve a column that is an array. To be exact, I would like to get the AutomationTasks for a certain Automation.

This is my code:

var prox = new Script.Util.WSProxy();
var data = prox.retrieve("Automation", 
                         ["Name", "CustomerKey", "AutomationTasks"], // columns
                         { Property: "Name", SimpleOperator: "equals", 
                           Value: "NAME_OF_AUTOMATION"} // filter

As soon as I add AutomationTasks to the columns, I also tried AutomationTasks[], AutomationTasks[0] etc, but it all gets errors. I don't think I can retrieve an AutomationTask directly.

See here an overview of the Automation object: https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/automation.htm

Has anyone been successful getting a column which is an array through WSProxy.retrieve()?


What I would do, which is not exactly the most performant method, but works well for me is to retrieve the column of "*" (wildcard) which returns all columns. (This wildcard does not work for all objects, only certain ones.)

You can then break down the Results to grab your Automation Tasks Array or refine it further to get the Activities Array.

One thing to note is that if there is more than one Automation Task, for some reason the resulting AutomationTasks array will be all null. See this question for more info.

So you will need to retrieve the ObjectID of your automation in one WSProxy call and use that inside a second call to the Activities or Tasks Object to get this info.

Please note that we are using the old 'Program' objects here and not the new 'Automation' objects that are in the documentation. The Automation objects seem to be incomplete, so they do not offer the same capabilities that the older objects do.

So the following should get you what you need:

<script runat=server>

//WSProxy API to get ObjectID of Automation

var prox = new Script.Util.WSProxy();

var cols = ["Name", "ObjectID"]; // columns
var filter = {Property: "Name", SimpleOperator: "equals", Value: "gg_test"}; // filter

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

//Set ObjectID to var
var objID = data.Results[0].ObjectID

//WSProxy API to get Activity Information

var api = new Script.Util.WSProxy();

var cols2 = ["Name", "ObjectID","Description","Sequence"] // columns
var filter2 = {Property: "Program.ObjectID", SimpleOperator: "equals", Value: objID} // filter

var rr = prox.retrieve("Activity", cols2, filter2);


You then use the rr var resulting JSON to grab the info you need.

  • Thanks, this works! Using the WSProxy.describe('Program') method also gives additional insights in what fields are in these undocumented objects (got that thanks to the link you gave to the other question). This definitely helped me a step further, but unfortunately the Activity object does not seem to give much information about the activity (whether it is a Query or a Script for example). But afraid that's just a limitation of the API, also given responses in the other question. – Jhu884 Apr 10 at 7:10
  • Check out the following for info on how to associate the activity 'type' with the activity returned from the above. Please note that this is not a performant method and far from optimal, but it is the only way I am aware of: salesforce.stackexchange.com/questions/254614/… – Gortonington Apr 10 at 12:43

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.