Hi all,
We reuse items for some generic transactions, and as a result, the last direct cost always populates as direct unit cost in the purchase quote subform (purchase line).
I would like to do the following:
I have tried several code approaches, but I can't even get my code to hit a breakpoint, which gives me the suspicion I'm not even writing code in the right place
Please see some examples below....thank you in advance
BELOW IS WRITTEN IN: modify(No.) IN PURCHASE QUOTE SUBFORM PAGE EXTENSION
BELOW IS WRITTEN IN: modify(No.) IN ITEM LOOKUP PAGE EXTENSION
Hi Mohana,
This is a fantastic answer and works perfectly. It is robust and well thought out....thank you!
You can use the following code
[EventSubscriber(ObjectType::Table, Database::"Purchase Line", 'OnAfterUpdateDirectUnitCost', '', false, false)]
local procedure OnAfterUpdateDirectUnitCost(var PurchLine: Record "Purchase Line"; xPurchLine: Record "Purchase Line"; CalledByFieldNo: Integer; CurrFieldNo: Integer);
var
Item: Record Item;
begin
if PurchLine."Document Type" = PurchLine."Document Type"::Quote then
if PurchLine.Type = PurchLine.Type::Item then begin
Item.Get(PurchLine."No.");
if Item.Type = Item.Type::"Non-Inventory" then begin
item."Last Direct Cost" := 0;
PurchLine.Validate("Direct Unit Cost", 0);
Item.Modify();
end;
end;
end;
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,113 Super User 2024 Season 2
Martin Dráb 229,918 Most Valuable Professional
nmaenpaa 101,156