- Code: Select all
var a= globals.gstartdate;
for ( var i = 1 ; mdate < globals.genddate ; i++ )
{
controller.newRecord();
var a= globals.gstartdate;
mdate=a.setDate(a.getDate()+i);
}
1)
var a= globals.gstartdate; is declared twice.
2) mdate=a.setDate(a.getDate()+i);
you're trying to set datefield(?)
mdate with an integer.
a.setDate(a.getDate()+i) returns an integer
3)
for ( var i = 1 ; mdate < globals.genddate ; i++ ) Seems to me you first have to define the foundset you want to loop through:
-search for all records that have mdate < globals.genddate
- then do
for ( var i = 1 ; i< controller.getMaxRecordIndex(); i++ ) So here's how I would do it:
- Code: Select all
//search for all records that have mdate < globals.genddate
//in order to define the foundset you are going to loop through.
var a= globals.gstartdate; //declare dateObject a only once
for ( var i = 1 ; i<= controller.getMaxRecordIndex(); i++ )
{
controller.newRecord(); //IMPORTANT: create your records in an other table then the one you are looping through, otherwise your loop will never stop. (i will always be smaller then controller.getMaxRecordIndex()
a.setDate(a.getDate()+1); //increase a(dateObject) with one day
mdate= a //set mdate(datefield) with (a)(dateObject)
mday = a.getDate(); //set mday(integer field) with a.getDate()(integer result)
}