1

I saw this question about retrieving Automation info and I can't find how to do the basic task of retrieving information about all the automations in a folder with given CategoryID (=folderID) as I made before with Data Extensions or Query Activities using

this

var folderQAs = QueryDefinition.Retrieve({Property:"categoryId",SimpleOperator:"equals",Value:folderID});)

or this

DataExtension.Retrieve({Property:"categoryId",SimpleOperator:"equals",Value:folderID})

Is there something similar to Automations? (like this)

Automation.Retrieve({Property:"categoryId",SimpleOperator:"equals",Value:folderID})

I got a list of all automations/journeys/unknownThings with the following code:

var cols =  ["Name", "Status", "ModifiedDate", "CustomerKey", "ObjectID"
            ];
var filter = {
  Property: "Status",
  SimpleOperator: "IN",
  Value: [-1,0,1,2,3,4,5,6,7,8]
};

var list = prox.retrieve("Program", cols, filter);
for(var a = 0; a < list.Results.length; a++) {
  Write(Stringify(list.Results[a]));  
}

Thank you in advance

1 Answer 1

0

You can use the filter on the CategoryID property (best ensure to be case sensitive) This next example works for data extensions; all you should have to do is replace the Object in the last line with "Automation", as all the properties are present on both objects:

<script type="javascript" runat="server">
 Platform.Load("core","1.1.5");
var prox = new Script.Util.WSProxy();
var props = { QueryAllAccounts: true };
var cols = ["Name","CustomerKey","CategoryID"];
var filter = {
    Property: "CategoryID",
    SimpleOperator: "equals",
    Value: 123456
};
var opts = {
    BatchSize: 25
};
var data = prox.retrieve("DataExtension", cols, filter, opts, props);</script>

Here is an example "the old fashioned way" with QueryDefinitions retrieved by a (complex, meaning >1 conditions) filter. You can see that it works off the same object structure, so the methods and objects are interchangeable. You could e.g. use this filter on CategoryID instead. Only make sure that you don't ask for properties that are not on the object. E.g. "IsSendable" would be only present on DEs.

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <s:Header>
        <fueloauth xmlns="http://exacttarget.com">{{accessToken}}</fueloauth>
    </s:Header>
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
            <RetrieveRequest>
                <ObjectType>QueryDefinition</ObjectType>
                <Properties>Name</Properties>
                <Properties>Description</Properties>
                <Properties>CustomerKey</Properties>
                <Properties>ObjectID</Properties>
                <Properties>Status</Properties>
                <Filter xsi:type="par:ComplexFilterPart" xmlns:par="http://exacttarget.com/wsdl/partnerAPI">
                <LeftOperand xsi:type="par:SimpleFilterPart">
                  <Property>Status</Property>
                  <SimpleOperator>equals</SimpleOperator>
                  <Value>Active</Value>
               </LeftOperand>
               <LogicalOperator>AND</LogicalOperator>
               <RightOperand xsi:type="par:SimpleFilterPart">
                  <Property>Name</Property>
                  <SimpleOperator>equals</SimpleOperator>
                  <Value>gmx_Day1_week1</Value>
               </RightOperand>
            </Filter>
            </RetrieveRequest>
        </RetrieveRequestMsg>
    </s:Body>
</s:Envelope>

It's good to familiarize yourself with SSJS filters;

For the general use of simple and complex filters, here is a good explanation: How can I create a ComplexFilterPart using SSJS / API in Marketing Cloud?

...and here is an example to apply a complex filter in WSProxy: SSJS Complex filter with more than one propertie

some more useful WSproxy examples: https://github.com/jdeblank/sfmc_dev/tree/master/wsproxy

operators are documented here, albeit a little "shady" as definitions like "works on most objects" are used unironically: https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/simpleoperators.htm

And you can of course find the objects here: https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/soap_web_service_objects.html

You must log in to answer this question.

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