Retrieve the Status of Programs Using AsyncActivityStatus

This page contains information about retrieving the status of programs using the Campaign object (representing the program itself) and AsyncActivityStatus.

Why Retrieve the Status of Programs 

You can view the status of active programs to determine how far along these processes are and determine further action from that point.

How to Retrieve the Status of Programs 

Use the sample code below as a model to construct your own API call. Note that this Retrieve call ignores the DateValue property of the SimpleFilterPart and the operand for the ComplexFilterPart. The call returns information about calls started between the StartTime and EndTime only.

You can only set up your filters to use the following properties:

  • ParentInteractionObjectID
  • TaskID
  • StartTime
  • EndTime
  • ClientID
  • QueryAllChildren

The call returns ObjectExtension instances for each program that can include the following information:

  • ParentInteractionObjectID
  • ParentTaskID
  • Program
  • ProcessID
  • StepID
  • StepTaskID
  • StepName
  • InteractionID
  • ClientID
  • TaskID
  • ActionType
  • Type
  • AsyncAction
  • AsyncSubAction
  • Status
  • ProcessedCount
  • TotalCount
  • DuplicateCount
  • ErrorCount
  • CustomerKey
  • ErrorMsg
  • ScheduledTime
  • StartDate
  • CompletedDate
  • StatusMessage

Note that this call can return a large amount of information that could cause timeouts. If you encounter this problem, break your request into several smaller calls.

Sample .NET Code 

1RetrieveRequest request = new RetrieveRequest();
2// Step 1: This is the object type for async activity statuses
3request.ObjectType = 'AsyncActivityStatus';
4// Step 2: Select the properties you want request.
5request.Properties = new string[] { 'CompletedDate', 'Program', 'StepName', 'ActionType', 'Type', 'Status', 'ProcessedCount', 'TotalCount', 'DuplicateCount', 'ErrorCount', 'CustomerKey', 'ErrorMsg', 'StatusMessage' };
6// Step 3: Define the filter to get the last two hours worth of activity
7ComplexFilterPart filter = new ComplexFilterPart();
8// AsyncActivityStatus is a very special case, for date queries the string value is used, not DateValue
9        filter.LeftOperand = new SimpleFilterPart() {
10        Property = 'StartTime',
11        Value = new string[] { DateTime.Now.AddHours(-2).ToString() } };
12// filter.LogicalOperator = LogicalOperators.AND;
13// For AsyncActivityStatus, the LogicalOperator is not relevant/required
14        filter.RightOperand = new SimpleFilterPart() {
15            Property = 'EndTime',
16            Value = new string[] {
17            DateTime.Now.ToString()} };
18            request.Filter = filter;
19            string requestId;
20            APIObject[] results;
21            string response = soapClient.Retrieve(request, out requestId, out results);

Sample Java Code (Axis 1.4) 

1public void testGetCampaignStatus() throws RemoteException {
2         try {
3     Soap stub = init();
4                String[] props = {"Program", "StepName", "ActionType", "Type", "Status", "ProcessedCount", "TotalCount", "DuplicateCount", "ErrorCount", "CustomerKey", "ErrorMsg", "CompletedDate", "StatusMessage"};
5                RetrieveRequest retrieveRequest = new RetrieveRequest();
6                        retrieveRequest.setProperties(props);
7                retrieveRequest.setObjectType("AsyncActivityStatus");
8                    SimpleFilterPart filter1 = new SimpleFilterPart();
9                filter1.setProperty("StartTime");
10                filter1.setSimpleOperator(SimpleOperators.equals);
11                        Calendar aCalStartDate = new GregorianCalendar();
12                //public final void set(int year, int month, int date, int hourOfDay, int minute)
13                aCalStartDate.set(2010, 8, 15, 1, 0); //today-10
14                String sDate = DateFormat.getInstance().format(aCalStartDate.getTime());
15                GregorianCalendar[] aCal = new GregorianCalendar[]{(GregorianCalendar) aCalStartDate};
16                filter1.setDateValue(aCal);
17                filter1.setValue(new String[]{sDate});
18                        System.out.println(" 1. " + DateFormat.getInstance().format(aCalStartDate.getTime()));
19                    Calendar aCalEndDate = new GregorianCalendar();
20                //public final void set(int year, int month, int date, int hourOfDay, int minute)
21                aCalEndDate.set(2010, 8, 26, 23, 59); //today-10
22                String eDate = DateFormat.getInstance().format(aCalEndDate.getTime());
23                        SimpleFilterPart filter2 = new SimpleFilterPart();
24                filter2.setProperty("EndTime");
25                filter2.setSimpleOperator(SimpleOperators.equals);
26                GregorianCalendar[] bCal = new GregorianCalendar[]{(GregorianCalendar) aCalEndDate};
27                filter2.setDateValue(bCal);
28                filter2.setValue(new String[]{eDate});
29
30                System.out.println(" 3. " + DateFormat.getInstance().format(aCalEndDate.getTime()));
31                    ComplexFilterPart cFilter = new ComplexFilterPart();
32                cFilter.setLeftOperand(filter1);
33                cFilter.setRightOperand(filter2);
34                cFilter.setLogicalOperator(LogicalOperators.OR);
35                    retrieveRequest.setFilter(cFilter);
36                    RetrieveRequestMsg retrieveRequestMsg = new RetrieveRequestMsg();
37                retrieveRequestMsg.setRetrieveRequest(retrieveRequest);
38                RetrieveResponseMsg retrieveResponseMsg = stub.retrieve(retrieveRequestMsg);
39                System.out.println("[overall status message] " + retrieveResponseMsg.getOverallStatus());
40                APIObject[] apiObjectList = retrieveResponseMsg.getResults();
41                    if (apiObjectList != null && apiObjectList.length > 0) {
42                    for (APIObject dumpStepThrough : apiObjectList) {
43                       ObjectExtension s = (ObjectExtension) dumpStepThrough;
44                        if(s.getProperties()!=null && s.getProperties().length >0){
45                            for(APIProperty api: s.getProperties()){
46                                System.out.println("Name :: " + api.getName() + "       Value ::: " + api.getValue() );
47                            }
48                        }
49                    }
50                }
51                } catch (Exception e) {
52                e.printStackTrace();
53            }
54       }

Sample SOAP Envelope 

1<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2   <soapenv:Header>
3      <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
4         <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
5            <wsse:Username>XXXXX</wsse:Username>
6            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">XXXXX</wsse:Password>
7         </wsse:UsernameToken>
8      </wsse:Security>
9   </soapenv:Header>
10   <soapenv:Body>
11      <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
12         <RetrieveRequest>
13            <ObjectType>AsyncActivityStatus</ObjectType>
14            <Properties>Status</Properties>
15            <Properties>StartTime</Properties>
16            <Properties>EndTime</Properties>
17            <Properties>TaskID</Properties>
18            <Properties>ParentInteractionObjectID</Properties>
19            <Properties>InteractionID</Properties>
20            <Filter xsi:type="SimpleFilterPart">
21               <Property>ParentInteractionObjectID</Property>
22               <SimpleOperator>equals</SimpleOperator>
23               <Value>8f083fc7-0439-df11-b817-00237d540dfc</Value>
24            </Filter>
25            <!--Only can filter on ParentInteractionObjectID, TaskID, StartTime, and EndTime-->
26         </RetrieveRequest>
27      </RetrieveRequestMsg>
28   </soapenv:Body>
29</soapenv:Envelope>

Sample SOAP Envelope Using Complex Filter 

1<soap-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2 <SOAP-ENV:Header>
3 <wsse:Security mustUnderstand="true" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
4 <wsse:UsernameToken>
5 <wsse:Username>XXXXX</wsse:Username>
6 <wsse:Password>XXXXX</wsse:Password>
7 </wsse:UsernameToken>
8 </wsse:Security>
9 </SOAP-ENV:Header>
10 <SOAP-ENV:Body>
11 <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
12 <RetrieveRequest>
13 <Options>
14 <Client>
15 <ID>REPLACE with MID</ID>
16 </Client>
17 </Options>
18 <ObjectType>AsyncActivityStatus</ObjectType>
19 <Properties>Status</Properties>
20 <Properties>StartTime</Properties>
21 <Properties>EndTime</Properties>
22 <Properties>ErrorMsg</Properties>
23 <Properties>CompletedDate</Properties>
24 <Properties>StatusMessage</Properties>
25 <Properties>TaskID</Properties>
26 <Properties>ParentInteractionObjectID</Properties>
27 <Properties>InteractionID</Properties>
28 <Filter xsi:type="par:ComplexFilterPart" xmlns:par="http://exacttarget.com/wsdl/partnerAPI">
29 <LeftOperand xsi:type="par:SimpleFilterPart">
30 <Property>TaskID</Property>
31 <SimpleOperator>equals</SimpleOperator>
32 <Value>ccc</Value>
33 </LeftOperand>
34 <LogicalOperator>AND</LogicalOperator>
35 <RightOperand xsi:type="par:SimpleFilterPart">
36 <Property>StartTime</Property>
37 <SimpleOperator>greaterThan</SimpleOperator>
38 <Value>XXXX-XX-XX</Value>
39 </RightOperand>
40 </Filter>
41 </RetrieveRequest>
42 </RetrieveRequestMsg>
43 </SOAP-ENV:Body>
44</SOAP-ENV:Envelope>