I have some code which doesn't seem to loop through the i variable incrementally... any ideas where I'm going wrong?
<script runat="server">
Platform.Load("core","1.1");
var DE1 = DataExtension.Init("abc-123-def-456");
var MaxIt = DE1.Rows.Retrieve();
for (var i = 0; i < MaxIt.length; i++)
{
var IT = Platform.Function.Lookup('SSJS_Query_updating_01','QueryExternalKey','Row',[i]);
var qd = QueryDefinition.Init(IT);
var QT1 = "SELECT MR.* FROM masterDE MR ";
var QT2 = "WHERE 1 + 1 = "
var QT3 = [i];
var status = qd.Update({
QueryText: QT1 + QT2 + QT3
});
status.Perform()
}
the MaxIT DE has two rows with, so i expect this to loop through both rows picking up the ext key for the two queries and re-writing both exactly the same as above. I suspect that i am not using the [i] iteration correctly but not sure
UPDATE
I have tweaked the code and simplified what I am asking but i can only get one of the two queries in the data extension to update and it's always the second row of the two rows in the data extension. Anything in this code that stands out as to why both query definitions sitting in the fields won't update?
<script runat="server">
Platform.Load("core","1.1");
var DE1 = DataExtension.Init("abc-123-def-456");
var MaxIt = DE1.Rows.Retrieve();
for (var i = 1; i = MaxIt.length; i++)
{
var IT = Platform.Function.Lookup('SSJS_Query_updating_01','QueryExternalKey','Row', [i] + 1);
var qd = QueryDefinition.Init(IT);
var QT1 = "SELECT M.* ";
var QT2 = "FROM [masterDE] M";
var status = qd.Update({
QueryText: QT1 + QT2
});
status.Perform();
}
</script>
Note i've added i + 1... i can't get it to update even one query without putting the +1 there
WHERE 1 + 1 = [0]
or1+1 = 0
for first iteration? What is the purpose of the brackets you have there?