Print this page

Example use of Server-Side JavaScript in a Marketing Cloud landing page

Knowledge Article Number 000232465
Description
This example code placed within a landing page or microsite will return the name of an Automation based on a Customer Key value that's input into the code by replacing the text "ExampleCustomerKey" with an External Key of one of your Automations. You can dictate what property you would like returned by replacing the "program[i].Name" code with "program[i].[Property you wish to return]"
Resolution  

Sample code

 
<html>
    <head>
    </head>
    <body>


        <table style= "border: 1px solid black">
            <tr>
                <td>Activity</td>
            </tr>
            <script runat=server>  
                Platform.Load("Core","1");
                var program = Program.Retrieve({Property:"CustomerKey",SimpleOperator:"equals",Value:"ExampleCustomerKey"});
			for (var i = 0; i < program.length; i++) 
                	{
                    		Write("<tr>");
                    		Write("<td>" + program[i].Name + "</td>");
                    		Write("</tr>");
			}
               // Write(Stringify(program));
            </script>
        </table>
    </body>
</html>


Want to learn more about SSJS? Review our documentation on the topic. 




promote demote