I am trying to update a query definition in Marketing cloud using SSJS script which updates the query based on the datestamp. When I run the script, I don't get any error but it does not seem to be updating the query definition for some reason. The script is below:
<script language="javascript" runat="server">
Platform.Load("core", "1");
var qd = QueryDefinition.Init("37af1441-0b0c-4f99-b8ac-ac511da5ff2c");
var today = new Date();
var dd = today.getDate()+1;
var mm = today.getMonth()+1;
var yyyy = today.getFullYear();
var year = yyyy.toString();
var yy = year.substring(2);
var send_date = (today.getMonth() + 1) + "-" + (today.getDate() + 1) + "-" + yy;
var str1 = "]";
var dename = "10-ControlGroup-MyWeekend-" + yyyy + mm + dd + str1;
var sql = "Select A.EmailAddress as Email, 2 as [Campaign ID], 1 as [Control Group],'" + send_date + " 12:00:00 AM' as [Send Date], B.[Janrain ID] as [Janrain ID] FROM [" + dename + " A INNER JOIN [Subscribers] B on A.EmailAddress = B.EmailAddress" ;
var status = qd.Update({
Name : "Control Group - Query to Populate MyWeekend History Log - UPDATED",
QueryText : sql
});
qd.Perform();
</script>
Would anyone know why it might not be working as expected? Thanks for your help in advance.
Cheers, Gaurav
status
). So something likeWrite(Stringify(status))