2

I'm trying to use SSJS to retrieve the automation activities of an automation, using this code:

var api = new Script.Util.WSProxy();
var cols = ['Name', 'CustomerKey', 'AutomationTasks'];
var automation = api.retrieve('Automation', cols, { Property : 'CustomerKey', SimpleOperator : 'equals', Value : key });
Write(Stringify(automation));

However, the receive the following response:

{
  "Status": "OK",
  "RequestID": "c12d8343-e5cb-4165-aa98-b3503879ac30",
  "Results": [
    {
      "Client": null,
      "PartnerKey": null,
      "PartnerProperties": [
        {
          "Name": "ErrorMessage",
          "Value": "Invalid column name 'AutomationTasks'."
        },
        {
          "Name": "ErrorStackTrace",
          "Value": "Invalid column name 'AutomationTasks'."
        }
      ],
      "CreatedDate": "0001-01-01T00:00:00.000",
      "ModifiedDate": null,
      "ID": 0,
      "ObjectID": null,
      "CustomerKey": null,
      "Owner": null,
      "CorrelationID": null,
      "ObjectState": null,
      "IsPlatformObject": false
    }
  ],
  "HasMoreRows": false
}

I got the AutomationTasks from here. This page also seems to use it too. Anyone know what I'm doing wrong?

1 Answer 1

6

The issue is that the column AutomationTasks is not a retrievable property in the Automation object.

From Describe call on the object:

        <Properties>
            <PartnerKey xsi:nil="true" />
            <ObjectID xsi:nil="true" />
            <Name>AutomationTasks</Name>
            <DataType>AutomationTask[]</DataType>
            <IsUpdatable>true</IsUpdatable>
            <IsRetrievable>false</IsRetrievable>
        </Properties>

For the 'Automation' Object, if you use the wildcard(*) in the property for the lookup, you can gather more information:

    <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <RetrieveRequest>
            <ObjectType>Automation</ObjectType>
            <Properties>*</Properties>
            <Filter xsi:type="SimpleFilterPart">
                <Property>ProgramID</Property>
                <SimpleOperator>equals</SimpleOperator>
                <Value>9bee2fc2-38db-4aa0-806c-a618850edd5f</Value>
            </Filter>
        </RetrieveRequest>
    </RetrieveRequestMsg>

Although it will return the info if there is only 1 task, there is a bit of a 'bug' in this object that if there is more than one task it will return an empty array (see here for more info)

So the solution to get a list of all the tasks/activities in your Automation is by doing a call to the Object 'Activity' (again an old Object that is no longer documented)using the Program.ObjectID (which can be gathered from the call to Program).

Gather the Program.ObjectID:

<RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
    <RetrieveRequest>
        <ObjectType>Program</ObjectType>
        <Properties>Program.ObjectID</Properties>
        <Properties>Name</Properties>
        <Filter xsi:type="SimpleFilterPart">
            <Property>Name</Property>
            <SimpleOperator>equals</SimpleOperator>
            <Value>[my automation name]</Value>
        </Filter>
    </RetrieveRequest>
</RetrieveRequestMsg>

and then the call to 'Activities' object:

<RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
    <RetrieveRequest>
        <ObjectType>Activity</ObjectType>
        <Properties>Name</Properties>
        <Properties>Description</Properties>
        <Properties>ObjectID</Properties>
        <Properties>Step</Properties>
        <Filter xsi:type="SimpleFilterPart">
            <Property>Program.ObjectID</Property>
            <SimpleOperator>equals</SimpleOperator>
            <Value>[objectid from step 1]</Value>
        </Filter>
    </RetrieveRequest>
</RetrieveRequestMsg>

This should return all available activities inside the Automation. There is also an Object called 'Task' that you should be able to use to gather just task related items. More details on that Object are available via Describe or in the question I linked to above.

You must log in to answer this question.

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