Hi everyone,
I want to update my unit price field in the Item table to the Unit Price field in the Sales Price Table based on the Sales Code. I currently just keep getting every Item card to update to the first record in the table. I have the following code. Pretty new to writing code so please be patient.
Item - OnPreDataItem()
SalesPriceRec.SETCURRENTKEY(SalesPriceRec."Item No.");
SalesPriceRec.SETRANGE(SalesPriceRec."Sales Type", SalesPriceRec."Sales Type" :: "Customer Price Group");
SalesPriceRec.SETRANGE(SalesPriceRec."Sales Code", 'DEALER');
TotalRecords := COUNT;
i := 0;
DialogWindow.OPEN('Updating Unit Prices for all Items @1@@@@@@@');
i := i + 1;
Completed := ROUND((i / TotalRecords) * 10000,1);
DialogWindow.UPDATE(1,Completed);
Item - OnAfterGetRecord()
IF SalesPriceRec.FIND('-') THEN BEGIN;
Item."Unit Price" := SalesPriceRec."Unit Price";
MODIFY;
END;
i := i + 1;
Completed := ROUND((i / TotalRecords) * 10000,1);
DialogWindow.UPDATE(1,Completed);