[SalesForce] Returning the complete results from a Data Extension including field names

First question on here and new user of Ampscript – please be gentle!

Primarily for debug purposes I would like to use the LookupRows function to return a subset of rows from a number of Data Extensions, but rather than then returning a specific field I would like to return all the fields from all the rows including the header row.

As I will be repeating this process on Data Extensions of all shapes and sizes, I was looking for a way to do with programatically, and thus dynamically deal with Data Extensions with different field and row counts.

I did look through the documentation but couldn't find an example, or even a function that would return a field header.

Best Answer

Have you tried server side javascript for this? You can either get all the fields returned as a JSON object:

http://help.exacttarget.com/zh-HK/documentation/exacttarget/content/server_side_javascript/server_side_javascript_syntax_guide/core_library_server_side_javascript_functions/data_extension_server_side_javascript_functions/#section_11

or even get all the rows with all fields as a JSON object: http://help.exacttarget.com/zh-HK/documentation/exacttarget/content/server_side_javascript/server_side_javascript_syntax_guide/core_library_server_side_javascript_functions/data_extension_server_side_javascript_functions/#section_25

Note that the retrieve is limited to 2500 rows.

You can then access any of this data in ampscript by passing values between them. There are further articles on how to achieve this.

Related Topic