I like to show "created by" and "last updated by" information on a purchase order. I believe that there is no built-in mechanism except customizing and extending Purchase Header. I appreciate if someone can provide any feedback on this. Thanks.
I like to show "created by" and "last updated by" information on a purchase order. I believe that there is no built-in mechanism except customizing and extending Purchase Header. I appreciate if someone can provide any feedback on this. Thanks.
Okay Thanks. I also needed to update the code. I needed to call FindFirst() after setting the filter range as shown below. I believe that my issue was related with not calling FindFirst().
local procedure SetPurchaseHeaderUpdateStatus(purchaseHeaderCode: Code[50])
var
purchaseHeader: Record "Purchase Header";
begin
purchaseHeader.SetRange("No.", purchaseHeaderCode);
if purchaseHeader.FindFirst() then begin
purchaseHeader."Last Updated By" := UserId();
purchaseHeader."Last Updated On" := CurrentDateTime();
purchaseHeader.Modify();
end;
end;
With the above changes code works for both: adding a new line and updating existing lines. I am assigning value to purchaseHaderCode from Rec."Document No." while calling the above method from the triggers.
Again many thanks for your help and support.
I think you can remove the SetPurchaseHeaderUpdateStatus("Document No.") call from OnInsert trigger and leave only the call from OnModify.
Okay. Thanks a lot for your reply. However, what's about OnModify() trigger? I believe that a header should be available within database during update of any purchase line. I tried with that too and I received the same error. Any suggestion … . Thanks.
The SetPurchaseHeaderUpdateStatus is triggered in OnInsert trigger, do PurchaseHeader record is not yet wrote to the database and the MODIFY instruction will fail.
I like to update "last updated by" field I added on purchase header every time there is a new purchase line added or updated. Therefore, I extended "Purchase Line" table and added the following code for OnInsert and OnModify triggers.
trigger OnInsert() begin SetPurchaseHeaderUpdateStatus("Document No."); end; trigger OnModify() begin SetPurchaseHeaderUpdateStatus("Document No."); end; local procedure SetPurchaseHeaderUpdateStatus(purchaseHeaderCode: Code[50]) var purchaseHeader: Record "Purchase Header"; begin purchaseHeader.SetRange("No.", purchaseHeaderCode); purchaseHeader."Last Updated By" := UserId(); purchaseHeader."Last Updated On" := CurrentDateTime(); purchaseHeader.Modify(); end;
I receive the following error.
The purchase header does not exist. Identification field and values: Document Type: 'quote'; No.=''
During debug time I see that "purchaseHeader" is being assigned; code runs fine till I call purcahseHeader.Modify(). It looks like that it might be failing after Modify () method is called. Additionally, I am also wondering why the error message refers to the document type of quote when I am trying to fetch a purchase header.
I really appreciate if someone can help to resolve this issue.
Okay. thanks.
Yes, you need to:
1) Create a tableextension object for Purchase Header and add the fields you need, with logic for inserting the value on that fields (OnInsert/OnModify trigger)
2) Create a pageextension object and extends Purchase Order page for inserting that fields.
Very simple to do.
André Arnaud de Cal...
294,269
Super User 2025 Season 1
Martin Dráb
233,017
Most Valuable Professional
nmaenpaa
101,158
Moderator