I am working with client who has ancient marketing cloud implementation. There are huge number of automations which contain sql activities. Now the customer wants to change customer data model, which impact many sqls in sql activities. If the sqls is not updated, the automation will fail in production.
Instead of going through each automation (which will take weeks and there is a high risk of missing some changes), i want to extract all sqls to a Data extension. Then query that DE to find the sql activities which I need to change. Hope my question is clear.
I created a ssjs script (i dont have rights to create api user due to client regulations, thus i cannot use soap or reat apis) and trying to run in automation studio. It only give me 2500 records . I know there are more sql activities than 2500.
This is my script , can you tell me what is wrong.
<script runat="server">
Platform.Load("core", "1.1.5");
var InventoryDEIBM = "AutomationSQLActivityIBM";
var prox = new Script.Util.WSProxy(),
objectType = "QueryDefinition",
cols = ["Name", "CategoryID", "QueryText", "CustomerKey", "TargetUpdateType", "Status"],
moreData = true,
reqID = null,
numItems = 0;
clearDE(InventoryDEIBM);
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 ColArr = ["SeqNum", "Name", "CategoryID", "QueryText", "CustomerKey", "TargetUpdateType", "Status"];
var ValArr = [i + 1, data.Results[i].Name, data.Results[i].CategoryID, data.Results[i].QueryText, data.Results[i].CustomerKey, data.Results[i].TargetUpdateType, data.Results[i].Status];
var rows = Platform.Function.InsertData(InventoryDEIBM, ColArr, ValArr);
numItems++;
}
}
}
}
function clearDE(custKey) {
var action = "ClearData";
var props = {
CustomerKey: "AutomationSQLActivityIBM"
};
var data = prox.performItem("DataExtension", props, action);
return data;
}
</script>
I have run this script via cloud page and automation studio both. It fails (it give me "here is a problem with the resource you are looking for, and it cannot be displayed." error) after running for sometime. If i check the DE, i see 2500 records loaded.
Also how do i get the automation name , if i know the sql activity name , customer key etc.
I am expecting that the Data extension is loaded with all sql activity details including querytext