1

i'm now in my firsts baby steps in JavaScript on Salesforce Marketing Cloud.

In my script i read one Data Extension with an DataExtension.Init("DE") and a DE.Rows.Retrieve(filter). After this, some rows are analyzed and some modifications are made with a DE.Rows.Update. This process happens in a loop and the idea is when the DataExtension.Init("DE") is made in the loop 2 it reads the modified DE because of loop 1.

This process is not working properly, appears that the second DataExtension.Init("DE") is failing and the loop 2 is running over the first DE call. I'm doing something wrong or is this not possible?

In bellow is a sample of the code:

<script runat=server>

Platform.Load("core","1.1.1")

var today = new Date();
function AddDays(date, days){
    var result = new Date(date); result.setDate(result.getDate() + days)
    }

function Less5Minutes(date, minutes){
    var result = new Date(date);
    result.setMinutes(result.getMinutes() - minutes)
    } 

for (var u = 0; u <= 100; u++){

  var filter={LeftOperand: {
                            Property:      "column1",
                            SimpleOperator:"equals",
                            Value:         "NULL"
                            },
            LogicalOperator:"AND",
            RightOperand:{
                            Property:      "column3",
                            SimpleOperator:"lessThan",
                            Value:         Less5Minutes(today,5)
                            }
             };

  var DE= DataExtension.Init("DE");

  var DEclient = DE.Rows.Retrieve(filter);

  //Processing Rows part that result in something like:

  DE.Rows.Update({column1:"YES",column2: AddDays(today,2) },["ContactID","Name"],[Contact,RealName])}

}

</script>
  • Can you clarify what you mean by " appears that the second DataExtension.Init("DE") is failing and the loop 2 is running over the first DE call" I am not positive I understand. I did not see a second Init inside the sample code you provided. – Gortonington May 9 at 15:46
  • 1
    Hi Gortonington, when the "var DE= DataExtension.Init("DE")" runs in the second loop it became the second DE. But i already solved the problem and was not this, the problem was in the processing part inside the loop. Sorry for the inconvenience. – Pedro Pereira May 10 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.