Currently I am grabbing all of my public lists from Marketing Cloud and printing them out on the page, but I want to be able to print these out in a table format on the page, maybe by possibly using a for loop within the HTML. I have tried to do the for loop but it did not work.
Is there a way to print out these lists within a tag or something of the sort by possibly using AMPscript or something along the lines of that?
Here is my SSJS code:
<script type="text/javascript" runat="server">
Platform.Load("core", "1.1.1");
var debug = false;
var request = {};
SetVar("urlThis", Platform.Request.RequestURL);
if (Request.Method == "GET") {
if (debug) {
Write("GET<br/>");
}
Variable.SetValue("@email", Request.GetQueryStringParameter("cm_lm"))
} else if (Request.Method == "POST") {
if (debug) {
Write("POST<br/>");
}
Redirect(RESULTURL,false);
}
function SetVar(varName, varValue){
request[varName] = varValue;
Variable.SetValue(varName, varValue);
}
function isEmpty(str) {
return (!str || 0 === str.length);
}
if (debug) {
Write("<br><br>debug output: " + Stringify(request));
}
function getAllLists(mid) {
var rr = Platform.Function.CreateObject("RetrieveRequest");
Platform.Function.SetObjectProperty(rr, "ObjectType", "List");
Platform.Function.AddObjectArrayItem(rr, "Properties", "ID");
Platform.Function.AddObjectArrayItem(rr, "Properties", "ListName");
Platform.Function.AddObjectArrayItem(rr, "Properties", "Description");
var filter1 = Platform.Function.CreateObject("SimpleFilterPart");
Platform.Function.SetObjectProperty(filter1, "Property", "Type");
Platform.Function.SetObjectProperty(filter1, "SimpleOperator", "equals");
Platform.Function.AddObjectArrayItem(filter1, "Value", "Public");
var filter2 = Platform.Function.CreateObject("SimpleFilterPart");
Platform.Function.SetObjectProperty(filter2, "Property", "ListClassification");
Platform.Function.SetObjectProperty(filter2, "SimpleOperator", "notEquals");
Platform.Function.AddObjectArrayItem(filter2, "Value", "PublicationList");
var cfp = Platform.Function.CreateObject("ComplexFilterPart");
Platform.Function.SetObjectProperty(cfp, "LeftOperand", filter1);
Platform.Function.SetObjectProperty(cfp, "LogicalOperator", "AND");
Platform.Function.SetObjectProperty(cfp, "RightOperand", filter2);
Platform.Function.SetObjectProperty(rr, "Filter", cfp);
var clid = Platform.Function.CreateObject("ClientID");
Platform.Function.SetObjectProperty(clid, "ID", mid);
Platform.Function.AddObjectArrayItem(rr, "ClientIDs", clid);
var reqParams = [0, 0];
var Lists = Platform.Function.InvokeRetrieve(rr, reqParams);
return Lists;
}
var allPublicationLists = getAllLists(100008610);
for (var i in allPublicationLists) {
Write("\n" +allPublicationLists[i]["ListName"] + "|"
+allPublicationLists[i]["Description"]);
}
Write("TEST");
</script>