1

I have the following SSJS function which uses WSProxy to return an array of all business units, however, when I test the script in a CloudPage, it returns an error.

I'm hoping someone can take a look at the prox.retrieve() i put together and let me know what I am missing.

<script runat="server">
Platform.Load("Core","1.1.5");
try{

  var prox = new Script.Util.WSProxy(),
    queryAllAccounts = true,
    objectType = "Account",
    cols = ["ID","Name"],
    data = prox.retrieve(objectType, cols, queryAllAccounts)
    fields = [];
    for (var i=0; i<data.Results.length; i++) {
        fields.push({
            ID: data.Results[i].ID,
            name: data.Results[i].Name
        });
    }
    var de = DataExtension.Init('BusinessUnitDetails');
    var result = de.Rows.Add(fields);        
    Write("Result: " + result + " rows added")      


 }
 catch (err) {
  Write("Error Message: " + Stringify(err.message) + Stringify(err.description));
 }
</script>

4
  • What error does it return? – Gortonington Dec 15 '20 at 18:34
  • 500 Internal Server error – Sanket kharwade Dec 15 '20 at 18:42
  • If I remove var from data and fields, it returns: "Error Message: "Unable to retrieve security descriptor for this frame.""System.InvalidOperationException: Unable to retrieve security descriptor for this frame. - from mscorlib\r\n\r\n"" @Gortonington – Sanket kharwade Dec 15 '20 at 18:43
  • 1
    Was missing filter in prox.retrieve Its working now. – Sanket kharwade Dec 16 '20 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.