I need to retrieve a simple Boolean answer on a data extension asynchronously.

I believe that I can make an ajax call to a processing page and retrieve that data. However, I'm new to salesforce and AMPscript, and have no idea to return a value or print out a JSON from a data extension.

All my searches on google keep pushing me to Java or Apex API calls. If that is the only way to do this, then let me know so I can abandon this project.

  • Are you using CloudPages? If so, this is fairly straightforward and I can provide an example. Or are you trying to do this in an email? To confirm are you storing a JSON object in a DE field and you want to retrieve it? – Eliot Harper Mar 2 '17 at 16:59
  • Not using cloudPages, but using a microsite. So my tools are limited to Ampscript and javascript (client and server side). Correct, retrieve as a JSON. I can update via Ampscript, that seems straight forward enough. My hangup is on the retrieving end. – s.Lawrenz Mar 2 '17 at 17:07

Here's an online example that show how to retrieve data from a data extension using SSJS, which you can run from a microsite landing page.

The retrieve() function will return an array of objects in JSON format. You can output the results of the retrieve in this example by adding the following line of code.



If consuming this response from an ajax call, you might consider setting the content type to JSON when creating the landing page. Contact support if you do not see content type as an option on the landing page properties.

  • Beautiful, thank you. Now how do I access data that is printed on a page through an ajax call? – s.Lawrenz Mar 3 '17 at 16:08
  • client-side javascript will work for this. There are a number of online examples. I personally use the jquery library. (also see notes added to ticket). – David Devoy Mar 3 '17 at 16:10
  • Perfect. That works brilliantly. I had no idea you could set a page to JSON. – s.Lawrenz Mar 3 '17 at 16:24

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.