I'm attempting to create a CloudPage that will show intel on multiple types of objects when provided a drop downmenu. These are (1) Automations (2) Data Extensions (3) Email (4) EmailSendDefinition (5) TriggeredSendDefinition (6) QueryDefinition and (7) FilterActivity.
Using WSProxy, I was able to retrieve the total names for each of these but I'd like to extend it further to give me intelligence about fields for all of the pertinent objects.
For example, for the drop down menu option "Programs" which are the Automations ...I would like to simulate the display of all the columns seen in Automation Studio. I understand that other objects won't display these and I will address those later. For now, I'm able to display a large table displaying the names for all my automations. However, I can't seem to display the other fields.
So I figure maybe it would be helpful to display the key value pairs of everything found in the retrieve object. However, I'm unable to output everything at once. I able to display key value pairs for an Object in JavaScript using a variety of ways such as this below. However, this below doesn't work on data.Results.
var obj = { "1": 5, "2": 7, "3": 0, "4": 0, "5": 0 };
Object.keys(obj).forEach(function (key) {
document.write(key + ": " + obj[key] + "<br>");
});
I will display the code of what i'm using to output the names but I'm stuck in how to go about displaying data.Results. While I know that the the fields seen in Automation studio are 'Last Run Status', "Last Run' and 'Last Modified', I do not know for sure that these are the actual fields retrievable. There could be underscores. I checked the documentation to see what properties are found in Automations and I did not see these.
Can anyone help identify a good approach to helping achieve what I'm looking to do with the code below. I found a similar post with Accessing Dictionary Object here on stackexchange but it did not give me any additional insight on how to make my code work.
<h1>Show a list of all Objects</h1><br>
%%[
var @selectedObjectType
SET @selectedObjectType = RequestParameter("ObjectType")
]%%
<form action="%%=RequestParameter('PAGEURL')=%%" method="POST">
<select name="ObjectType">
%%[IF @selectedObjectType != "" THEN ]%%
<option select="%%=v(@selectedObjectType)=%%">%%=v(@selectedObjectType)=%%</option>
%%[IF @selectedObjectType != "DataExtension" THEN ]%%
<option value="DataExtension">DataExtension</option>
%%[ENDIF ]%%
%%[IF @selectedObjectType != "Email" THEN ]%%
<option value="Email">Email</option>
%%[ENDIF ]%%
%%[IF @selectedObjectType != "EmailSendDefinition" THEN ]%%
<option value="EmailSendDefinition">EmailSendDefinition</option>
%%[ENDIF ]%%
%%[IF @selectedObjectType != "Program" THEN ]%%
<option value="Program">Program</option>
%%[ENDIF ]%%
%%[IF @selectedObjectType != "TriggeredSendDefinition" THEN ]%%
<option value="TriggeredSendDefinition">TriggeredSendDefinition</option>
%%[ENDIF ]%%
%%[IF @selectedObjectType != "QueryDefinition" THEN ]%%
<option value="QueryDefinition">QueryDefinition</option>
%%[ENDIF ]%%
%%[IF @selectedObjectType != "FilterActivity" THEN ]%%
<option value="FilterActivity">FilterActivity</option>
%%[ENDIF ]%%
%%[ELSE ]%%
<option value="DataExtension">DataExtension</option>
<option value="EmailSendDefinition">EmailSendDefinition</option>
<option value="Email">Email</option>
<option value="Program">Program</option>
<option value="TriggeredSendDefinition">TriggeredSendDefinition</option>
<option value="QueryDefinition">QueryDefinition</option>
<option value="FilterActivity">FilterActivity</option>
%%[ENDIF ]%%
</select>
<input type="submit" class="submit" value="Submit">
</form>
<script language="javascript" runat="server">
Platform.Load("Core", "1");
var debug = 1;
if (Request.Method == "POST" && Request.GetFormField("Name") != "") {
var ObjectType;
ObjectType = Request.GetFormField("ObjectType");
var prox = new Script.Util.WSProxy(),
objectType = ObjectType,
cols = ["Name"],
moreData = true,
reqID = null,
numItems = 0;
Write("<table cellpadding='1' cellspacing='1' border='1'>");
Write("<thead>");
Write("<th>Object Name</th>");
Write("<th>Status</th>");
Write("<th>Last Run Status</th>");
Write("<th>Last Run</th>");
Write("<th>Last Modified</th>");
Write("</thead>");
Write("<tbody>");
while (moreData) {
moreData = false;
var data = reqID == null ?
prox.retrieve(objectType, cols) :
prox.getNextBatch(objectType, reqID);
if (data != null) {
moreData = data.HasMoreRows;
reqID = data.RequestID;
if (data && data.Results) {
for (var i = 0; i < data.Results.length; i++) {
var item = data.Results[i];
Write("<tr>");
Write("<td>");
Write(item.Name);
Write("</td>");
Write("<td>");
Write(item.Status);
Write("</td>");
Write("<td>");
Write(item['Last Run Status']);
Write("</td>");
Write("<td>");
Write(item['Last Run']);
Write("</td>");
Write("<td>");
Write(item['Last Modified']);
Write("</td>");
Write("</tr>");
numItems++;
}
}
}
}
}
Write("</tbody>");
Write("</table>");
</script>
Object.Keys
andforEach
are not available.