I have this code in the onopenpage of job journal page 201 which works fine to update changes in job journal.
But I also want it updated live, while the user is doing the changes. I've tried placing this code in onaftergetrecord but it just sets it to 0 and makes it worse. How do I make this work?
Totalcost := 0;
REPEAT
Totalcost := JobJournalLine."Total Cost" + Totalcost;
UNTIL JobJournalLine.NEXT = 0;
0
Answers
JobJournalLine.SETRANGE("Journal Template Name",'JOB');
JobJournalLine.SETRANGE("Journal Batch Name", CurrentJnlBatchName);
IF JobJournalLine.FIND('-') THEN
Totalcost := 0;
REPEAT
Totalcost := JobJournalLine."Total Cost" + Totalcost;
UNTIL JobJournalLine.NEXT = 0;
Just to add one thing, Always use FINDFIRST instead of FIND('-'), though both are same but as far optimization point of view FINDFIRST is much better. Secondly whenever use REPEAT UNTIL always use FINDSET instead of FINDFIRST.
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/