2

I'm looking for a way to use SSJS to retrieve results for various ImportDefinitions. I see that one could do it with API (here), but I'm not certain how that translates to SSJS.

Is there anything that would be something like the below? The below doesn't work in CloudPages and the "Write" does not give any results as to why it fails.

1   | <script runat=server>
2   |    Platform.Load("core","1");
3   |     
4   |    var results = ImportDefintion.Retrieve({Property:"ImportDefExternalKey",SimpleOperator:"equals",Value:"ImportDefName"});
4   |
5   |    Write(Stringify(results));
6   | </script>

1 Answer 1

3

Do a retrieve on "ImportResultsSummary" object via WSProxy.

<script runat="server">
Platform.Load("core","1.1.1");
try {
   var prox = new Script.Util.WSProxy();
   var cols = [
      "ImportDefinitionCustomerKey",
      "ImportType",
      "ImportStatus",
      "ID",
      "ObjectID",
      "NumberDuplicated",
      "NumberErrors",
      "NumberSuccessful",
      "DestinationID",
      "TaskResultID"
   ];
   var filter = {
      Property: "ImportDefinitionCustomerKey",
      SimpleOperator: "equals",
      Value: "123456789"
   };

   var result = prox.retrieve("ImportResultsSummary", cols, filter);
   Write("result: " + Stringify(result));
} catch(ex) {
    Write("An error has occurred: " + Stringify(ex));
}
</script>
2
  • That is being recognized in CloudPages, but it's throwing the error "result: {"Status":"Error: Index and count must refer to a location within the string.\r\nParameter name: count","RequestID":"xxxx-1234-xxxx","Results":null,"HasMoreRows":false}" instead of what's in var cols. Any chance you are able to recreate this error and know how to fix it? In the var filter "value" I'm placing the externalkey of the ImportDef ('xxxx...' is a placeholder).
    – Harley
    Commented Jul 26, 2019 at 1:10
  • 1
    @Harley I accidentally included the object in the cols array... oops. I have updated the example. Commented Jul 26, 2019 at 3:04

You must log in to answer this question.

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