2

Here's the code that I have (below). I'm trying to find out how I can retrieve a list of automations that do not have an "Error" notification recipient set. I did find the API field name called "Notifications" which is of data type AutomationNotification[] but this is marked as NOT "retrievable". Thus, it's returning a NULL value for what I expect to see the Notification recipients. Is there any way around this? We would love to have a list of ALL automations that do NOT have the error notification recipient set.

enter image description here

<script runat="server">

Platform.Load("Core","1.1.1");

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

  var cols = ["Name","Status","Notifications"];
  var filter = {
      Property: "Status",
      SimpleOperator: "IN",
      Value: [-1,0,1,2,3,4,5,6,7,8]
  };
  var res = prox.retrieve("Automation", cols, filter);

  if (res.Results.length > 0) {
      
      var statusObj = {
  "-1":"Error",
  "0":"BuildingError",
  "1":"Building",
  "2":"Ready",
  "3":"Running",
  "4":"Paused",
  "5":"Stopped",
  "6":"Scheduled",
  "7":"Awaiting Trigger",
  "8":"InactiveTrigger"
}
      
      Write('<table align="center" border="1" cellpadding="5" ><tr><th colspan="2">Automation Dashboard</th></tr>')
      for (var i = 0; i < res.Results.length; i++) {
          var autoName = res.Results[i].Name;
          var autoStatusNum = res.Results[i].Status;
          var autoStatus = statusObj[autoStatusNum];
          var autoNotifications = res.Results[i].Notifications;
          
          Write('<tr><td>' + autoName + '</td><td>' + Platform.Function.Stringify(autoNotifications) + '</td></tr>')
      }
      Write('</table>')
  }

</script>
3
  • 1
    What do you see when you write out Stringify(res.Results) in your debugging table? Aug 13, 2021 at 17:17
  • @AdamSpriggs thanks for the quick response! I see "null" (screenshot above) when I do that.
    – Mike Marks
    Aug 13, 2021 at 17:18
  • 1
    The WSDL would be the authority on whether it's really retrieveable or not. Sometimes the docs aren't correct. Aug 13, 2021 at 17:19

1 Answer 1

3

So, Notifications is technically not retrievable as a field in the Automation SOAP object. The cool thing though is that this object is one of the only objects that accepts the wildcard * to return all fields without listing them out. The best part about this is that it returns even some fields that are listed as not being able to be retrieved.

The caveat to being able to use the wildcard though (as it does not work by itself) is that you need to include "Customerkey" field in the columns/properties you are retrieving.

So for WSProxy it would be: var cols = [ "*", "CustomerKey" ];

and for SOAP it would be:

  <Properties>*</Properties>
  <Properties>CustomerKey</Properties>

Leaving you with the following WSProxy call:

<script runat="server">  
Platform.Load("Core","1.1.1");

var prox = new Script.Util.WSProxy(); 
var cols = [ "*", "CustomerKey" ];  
var filter = {
    Property: "Status",
    SimpleOperator: "IN",
    Value: [-1,0,1,2,3,4,5,6,7,8]
};
var data = prox.retrieve("Automation", cols, filter,opts,props);     
</script>

Which will return a child array like below when there is any notification information inside of the individual automation object:

"Notifications":[
   {
      "Address":"myemail@example.com",
      "Body":"my notification body copy",
      "ChannelType":"1",
      "NotificationType":"Error",
      "AutomationID":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "Client":null,
      "PartnerKey":null,
      "PartnerProperties":null,
      "CreatedDate":"0001-01-01T00:00:00.000",
      "ModifiedDate":null,
      "ID":0,
      "ObjectID":null,
      "CustomerKey":null,
      "Owner":null,
      "CorrelationID":null,
      "ObjectState":null,
      "IsPlatformObject":false
   }
]

Which should give you all the info you need.

You must log in to answer this question.

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