Advertisements

SF Marketing Cloud : Add and Display Data from Custom DE using JavaScript

Code snippet is provided below to fetch the First Name and Email Id from Custom DE. This code is written in SSJS.

<!doctype html>
 <html>
 <head>
 <!--Table Style-->
 <style>
 table, th, td {border: 1px solid black;}
 </style>
 <title>Add and Display Data from Custom DE using JavaScript</title>
 </head>
 <body>
 <H2>Add and Display Data from Custom DE using JavaScript</H2>
 <table style="width:100%">
 <tr>
 <th>NAME</th>
 <th>EMAIL ID</th>
 </tr>
 <!--Add Data-->
 <script runat=server language="JavaScript" >
 Platform.Load("Core","1");
 var de = DataExtension.Init('A_TEST_EXTERNAL_KEY');//Should be DE External Key Name
 de.Rows.Add({Name:'test',EmailId:'test@test.com'});
 </script>
 
 <!--Retrive Data-->
 <script runat=server language="JavaScript" >
 Platform.Load("Core","1");
 var de = DataExtension.Init('A_TEST_EXTERNAL_KEY');//Should be DE External Key Name
 var layouts = de.Rows.Retrieve();
 for (var i = 0; i < layouts.length; i++)
 {
 Write("<tr>");
 Write("<td>" + layouts[i].Name + "</td>");
 Write("<td>" + layouts[i].EmailId + "</td>");
 Write("</tr>");
 }
 </script>
 </table>
 </body>
 </html>
Advertisements


Categories: Salesforce Marketing Cloud

Tags: , , , , , , , , ,

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: