purchprice is not updated while creating purchline by code

purchprice is not updated while creating purchline by code

purchline1.PurchId = PurchTable.PurchId;

purchline1.ItemId = fieldItem.value();

purchline1.PurchQty = fieldQuantity.value();

purchLine1.PurchPrice = fieldUnitPrice.value();


inventDim1.InventSiteId = fieldSite.value();

inventDim1.InventLocationId = fieldwareHouse.value();

PurchLine1.InventDimId = InventDim::findOrCreate(inventdim1).inventDimId;

purchline1.CurrencyCode = Ledger::accountingCurrency(CompanyInfo::current());


Your price is being overwritten by the price from trade agreements i believe, the searchPrice parameter was set to true here.

For better implementation have a look at \Classes\PurchAutoCreate_PurchReq\createPurchLine

This call is not required, as the _initFromPurchTable parameter is also set to true

thanks for u reply kranthi

can u explain elabarate… how can i insert purchprice to purchline.purchprice

If you don’t want the system to search prices, then keep the search price parameter to false, have a look at code block in \Classes\PurchAutoCreate_PurchReq\createPurchLine where searchPrice was kept false

if (reqLine.LineType == PurchReqLineType::Category || reqLine.PurchRFQCaseId)


searchPrice = false;

purchLine.PurchPrice = reqLine.PurchPrice; // your price

purchLine.LineDisc = reqLine.LineDisc;

purchLine.LinePercent = reqLine.LinePercent;

purchLine.PurchMarkup = reqLine.PurchMarkup;

purchLine.LineAmount = purchLine.calcLineAmount();//calculate amount