I have a table with fields and Data as
No(PKey) Duration(int) Start Date End date
1 2 01/01/2011 03/01/2011
2 1 04/01/2011 05/01/2011
3 2 06/01/2011 08/01/2011
Now if I change value in Duration it should affect to all the records from the current field.
for Ex: if I Change Duration in 2nd record to 3 then End Date should change to 07/01/2011 and in next record start date should be 09/01/2011 and end date should be 11/01/2011 and so on… How to achieve it???Hope u ppl understood my question…
Try the below code on the OnValidate Trigger of the Duration Field in table, this will update all the records after the current record:
“End Date” := “Start date” + Duration1;
OldRec := Rec;
RecVar.SETFILTER(RecVar.“Entry No”,’>%1’,“Entry No”);
IF RecVar.FINDSET(TRUE) THEN REPEAT
RecVar.“Start date” := OldRec.“End Date”+1;
RecVar.“End Date” := RecVar.“Start date” + RecVar.Duration1;
OldRec := RecVar;
UNTIL RecVar.NEXT =0;
RecVar, OldVar are the Local record Variables of your Table XXX.
Hope this will help you.
You’ll definitely want to take a look at the CALCDATE function. You can look at NAV documentation, or search here for discussions involving the function.