I am trying to retrieve the column names from a shared data extension in the Marketing Cloud. I am using the follow code. This code is working with data extensions which are not in the shared items folder.

When I add "ENT." to the external key as mentioned in the documentation (to access a shared data extension) the code does not work any more and no columns are retrieved.

Documentation: http://help.exacttarget.com/en/documentation/exacttarget/content/server_side_javascript/server_side_javascript_syntax_guide/core_library_server_side_javascript_functions/data_extension_server_side_javascript_functions#section_4

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled document</title>
<style type="text/css">
html {
    padding: 10px;
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
<script runat=server>


var dataExtensionExternalKey = 'DATA_EXTENSION_EXTERNAL_KEY'; // USE ENT. to acces shared?
var dataExtensionFilterField = 'FILTER_COLUMN_NAME' // Column name to filter on
var dataExtensionOperator = 'equals'
var dataExtensionFilterValue = 'FILTER_COLUMN_VALUE' // Value to filter on

// SimpleOperator types: equals, notEquals
var dataExtensionFilter = {
    Property: dataExtensionFilterField,
    SimpleOperator: dataExtensionOperator,
    Value: dataExtensionFilterValue

var sourceDataExtension = DataExtension.Init(dataExtensionExternalKey); // Set Source data extension

var dataExtensionFields = sourceDataExtension.Fields.Retrieve(); // Retrieve the Data Extension columns

var dataExtensionFieldsLength = dataExtensionFields.length; // Set length to loop through all found column names


  <h1>DataExtension Columns Output</h1>
  <table border="0" cellpadding="0" cellspacing="0" class="table table-striped table-bordered table-hover table-condensed">
        <script runat=server>
        if (dataExtensionFieldsLength > 0) {
            // Write extra column for counting found records
            Write('<th>' + '#' + '</th>');

            // Write all column names
            for (var i = 0; i < dataExtensionFieldsLength; i++) {

  • The "ENT." is only necessary when assessing the shared data extension from a child business unit. If the code is executing in the parent business unit, then you should not include the "ENT." – David Devoy Jul 2 '15 at 21:15
  • My code is executing in a child business unit. Also I do not have the permissions to access the parent business unit. – Wesley Jul 3 '15 at 7:24
  • @Wesley Awesome Work could you please Work on same requirement through soap api I tried but iam not getting result.Please give me suggestion for to Acheive this requirement. – UserSFMC Mar 20 '18 at 13:48

You can access to shared Data Extensions with the LookupRows function.

var dataExtensionName = 'TEST';
dataExtensionName = 'ENT.'+dataExtensionName;

var result = Platform.Function.LookupRows(dataExtensionName,'ColumnName','Value');

//Write log output
Write('Result: '+Stringify(result)+'<br>');
  • OP is looking for Data Extension column names, not rows. – Adam Spriggs Jan 21 at 16:17

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.