0

I'm trying to retrieve the CustomObjectID of a data extension that already exists, by using the External Key/CustomerKey. That didn't work, so now I'm trying to retrieve any DEs at all, and that's not working either. Here is my code, I'm running it in a Landing page:

<script runat="server">
Platform.Load("Core","1");
var clientID = Attribute.GetValue('memberid');

var api = new Script.Util.WSProxy();
api.setClientId({"ID": clientID});
var cols = [ "Name", "CustomerKey", "CategoryID", "IsSendable"];
var res = api.retrieve("DataExtension",cols);
Write(res);

</script>

I don't get a JSON object back. What is written out is:

System.Collections.Generic.Dictionary`2[System.String, System.Object] 

I don't know what this means, except that there are no data extension objects to return? I'm literally following the exact example in the documentation:-

https://developer.salesforce.com/docs/atlas.en-us.mc-programmatic-content.meta/mc-programmatic-content/ssjs_WSProxy_basic_retrieve.htm

I can't even get the describe function to work:

var res = api.describe("DataExtension");

returns the same result -

System.Collections.Generic.Dictionary`2[System.String,System.Object] 

To add to the confusion, I can use describe and retrieve QueryDefinition objects and emailSendDefinition objects just fine - no issue there.

2

Change the last line to:

Write(Stringify(res));

Stringify will display the res variable that contains the response as JSON key and values with double quotes.

| improve this answer | |
0

turns out the issue was with the Stringify function. I did not notice it at the time, but I had a lowercase 's' in my code:

Write(stringify(res));

When I should have had

Write(Stringify(res));

And now everything actually works. The code block where I was using describe for QueryDefinition and EmailSendDefinition had the correct capitalized Stringify().

Lesson learned: starting a new code project on Friday afternoon before a holiday weekend is just not a good idea.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.