I figured out the problem and found a solution: The
sort by Added_Time desc; actually calls the record you are creating, so if you really want the last record before that you need to insert the criteria ID<input.ID (as shown in the corrected code below).
- test = input.Person;
- LastRecThisPerson = ThisForm [(Person = test && ID < input.ID && Added_Time == today)] sort by Added_Time desc;
- if (LastRecThisPerson.ID == null)
- {
- input.LapsedTimeInHours = 0.00;
- }
- if (LastRecThisPerson.ID > 100)
- {
- input.LapsedTimeInHours = ((zoho.currenttime - LastRecThisPerson.Added_Time) / 1000 / 60 / 60);
- }