0

I'm trying to retrieve data from AutomationInstance object via SOAP api. The object only supports IN and EQUALS operator. My sample request body is as per below -

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
   <s:Header>
        <fueloauth>*token*</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>AutomationInstance</ObjectType>
                <Properties>Name</Properties>
                <Properties>Description</Properties>
                <Properties>Status</Properties>
                <Properties>StatusMessage</Properties>
                <Properties>ScheduledTime</Properties>
                <Properties>StartTime</Properties>
                <Properties>CompletedTime</Properties>
                <Properties>ModifiedDate</Properties>
                <Properties>LastRunInstanceID</Properties>               
                <Filter xsi:type="SimpleFilterPart">
                    <Property>Name</Property>
                    <SimpleOperator>IN</SimpleOperator>
                    <Value>Feedback OR Survey Sent In Last 30 Days Suppressions Automation</Value>
                    <Value>Feedback Suppressions Automation</Value>
                    <Value>Survey and Customer Research - Subscription Suppressions Automation</Value>
                    <Value>Journey Email Activities DE</Value>
                    <Value>Best Practice - Subscription Suppressions Automation</Value>
                    <Value>Event - Subscription Suppressions Automation</Value>
                    <Value>Promotion - Subscription Suppressions Automation</Value>
                    <Value>Product - Subscription Suppressions Automation</Value>
                    <Value>Blog - Subscription Suppressions Automation</Value>
                    <Value>Customer Activity History Archive</Value>
                    <Value>Marketing Activities Extract</Value>
                    <Value>Journey Email Sent Extract</Value>
                    <Value>Customer Journey Activity Extract</Value>
                    <Value>Customer Journey Extract</Value>
                    <Value>Tracking Extract Automation</Value>
            </Filter>
         </RetrieveRequest>
      </RetrieveRequestMsg>
   </s:Body>
</s:Envelope>

The issue here is the I don't get the entire dataset in the response and it is limited to first 3-4 automations. I don't get data for any other automations even though the data is there. I tried with customerkey as well but same results. I'm wondering what am I'm doing wrong. Also, is there a way to limit the response to most recent run of the automation.

1 Answer 1

1

From what I have observed, I realized that the AutomationInstance object only retains the data for 6 months and I have no problems retrieving automations with the "IN" operator. So you may need to check these Automations to see if all of them ran at least once time during the past 6 months.

You can filter out by the automation name. However, I normally filter out by CustomerKey.

...Also, is there a way to limit the response to most recent run of the automation?

I don't think you can do with just the XML SOAP but have to process the response result to filter out.

In case, you can access and use Marketing Cloud SQL query, then I would propose using _AutomationInstance data view to get the information. It is much easier in my opinion.

The example code below, I get the formation from multiple automations with most recent start time (AutomationInstanceStartTime_UTC)

SELECT
      automation.MemberID
    , automation.AutomationName
    , automation.AutomationDescription
    , automation.AutomationCustomerKey
    , automation.AutomationInstanceID
    , automation.AutomationType
    , automation.AutomationNotificationRecipient_Complete
    , automation.AutomationNotificationRecipient_Error
    , automation.AutomationNotificationRecipient_Skip
    , automation.AutomationStepCount
    , automation.AutomationInstanceIsRunOnce
    , automation.FilenameFromTrigger
    , automation.AutomationInstanceScheduledTime_UTC
    , automation.AutomationInstanceStartTime_UTC
    , automation.AutomationInstanceEndTime_UTC
    , automation.AutomationInstanceStatus
    , automation.AutomationInstanceActivityErrorDetails
FROM _AutomationInstance AS automation
INNER JOIN
(SELECT
    a.AutomationCustomerKey
    , MAX(a.AutomationInstanceStartTime_UTC) as AutomationInstanceStartTime_UTC
FROM _AutomationInstance AS a
WHERE a.AutomationCustomerKey IN ('Your automation customer key 1', 'Your automation customer key 2', 'Your automation customer key 3', ...)
GROUP BY a.AutomationCustomerKey) AS b
ON
automation.AutomationCustomerKey = b.AutomationCustomerKey
AND automation.AutomationInstanceStartTime_UTC = b.AutomationInstanceStartTime_UTC

Notes: This data view only retains data in last 30 days and 24 hour delay before data is displayed

Reference from Salesforce official source: Data View: Automation Instance

You must log in to answer this question.

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