So I need to change my previous record (if it exists) of Sales Price.
When I insert a new record I need to fill the "Ending Date" field.
But my problem now is I tried this code
IF "Sales Price".INSERT(TRUE) THEN BEGIN
"Sales Price".RESET;
IF "Sales Price".FINDLAST THEN BEGIN
"Sales Price".NEXT(-1);
MESSAGE('data 2 %1 ',"Sales Price"."Starting Date");
"Sales Price"."Ending Date":=DataInicio-1;
"Sales Price".MODIFY(TRUE);
END;
But the previous record is not being modified... And the message shows the a wrong previous record like the image below...
I need to fill the field Ending Date right next to the date 08-11-2018 to close the last product price. In this case it should have the value (12-11-2018) but is not being filled for some reason.
My idea is when inserting a new record I always need to fill the Ending Date of my previous record. If I'm modifying a record already inserted in the system, the idea is to modify the existing record understand?
Answers
you could do
if salesprice.insert then
salespriceenddate.setfilters (new instance of sales price table- set the filters to get the line where you want to update the ending date)
if salespriceenddate.findfirst then
salespriceenddate.ending date:=DataInicio-1;
salespriceenddate.modify
if salesprice.insert then
salespriceenddate.setfilters (new instance of sales price table- set the filters to get the line where you want to update the ending date)
if salespriceenddate.findlast then
salespriceenddate.ending date:=DataInicio-1;
salespriceenddate.modify
pass the ending date not blank filter
This will fill the Ending Date of my current Line and not the previous one.. SO the price instead of 10.95 should be 12.65 (unit Price)
And worked...
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/