1

I'm having issues with the Account.Retrieve() SSJS core function. I was previously able to use this code to retrieve all Business Units in an Enterprise account:

<script runat=server>

Platform.Load('core', '1');

var filter = {
  Property: 'Name',
  SimpleOperator: 'NotEquals',
  Value: null,
  QueryAllAccounts: true
};

var getBUs = Account.Retrieve(filter);

Write(Stringify(getBUs));

</script>

While this script works in some enterprise accounts, it is now returning an empty array in other accounts. It used to work consistently across all Marketing Cloud accounts. I've tried changing the filter to include a BU name or MID, but it's still empty. I'm wondering if anyone else has experienced this and can suggest a workaround?

3
  • I have tried the exact same code, and it works fine. I am on stack51. Commented Jul 24 at 10:53
  • same, works for me, stack51. to narrow down if the operator is (or became) the problem, try a filter that relies on operator equals but also assumes nothing, like filter = { Property: 'IsActive', SimpleOperator: 'equals', Value: '1', QueryAllAccounts: true}; Commented Jul 24 at 13:35
  • This code actually does work, refer to my comment in answer below. Commented Jul 25 at 0:58

1 Answer 1

1

partially copied from comment: code works for me, stack51.

to narrow down if the operator is (or became) the problem, try a filter that relies on operator equals but also assumes nothing, like

filter = {  
Property: 'IsActive'
    ,SimpleOperator: 'equals'
    ,Value: '1'
    ,QueryAllAccounts: true
};
  • potential workaround or at least something to find our what the issue is:

retrieveRequest using SOAP API (which of course wont retrieve a JSON but an xml), just tried this successfully on stack7:

<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">
    <SOAP-ENV:Header>
       <fueloauth>{{accessToken}}</fueloauth>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
      <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">;
        <RetrieveRequest>
            <ObjectType>Account</ObjectType>
                <Properties>CustomerKey</Properties>
                <Properties>ID</Properties>
                <QueryAllAccounts>true</QueryAllAccounts>
         </RetrieveRequest>
      </RetrieveRequestMsg>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
1
  • 1
    This filter works too (returns the same result). Oddly enough, the code did not work on two accounts I tested yesterday and only worked on one, but today the code works on all Marketing Cloud accounts. Not sure if there was an availability issue? Marking answer as accepted, in appreciation for taking the time to validate! Commented Jul 25 at 0:57

You must log in to answer this question.

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