Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Update purchase header "posting description" with the line first line similar to the G/L entry

Posted on by 769
BC allows for us to carry the  line description to the General Ledger entry when posting. I would like to do similar but to the /Posting Description/. I know there is the code inthe Purchase Header:
    local procedure InitPostingDescription()
    var
        IsHandled: Boolean;
    begin
        IsHandled := false;
        OnBeforeInitPostingDescription(Rec, IsHandled);
        if IsHandled then
            exit;

        Rec./Posting Description/ := Format(Rec./Document Type/) + ' ' + Rec./No./;
    end;
 
 
 
What can I do before then to copy the first line description to the /Posting Description/ on the header? Is it creating a code unit event subscriber to the OnBeforeInitPostingDescription, or is there some other method?
 
Thanks,
 
Categories:
  • Suggested answer
    HVGEEL Profile Picture
    HVGEEL 288 on at
    Update purchase header "posting description" with the line first line similar to the G/L entry
    As you state correctly in your question: this is a HEADER function.
    In the header, things are rather straightforward: initialise the Psting Description to DocType + RecNo, allow the user to chage it afterwards.  End of story. Simple.
     
    If your requirement is to have the description of the first purchase line in the posting description, you will encouter a lot of issues along the way:
     
    - what if the first line gets deleted? Another line will become the first line and you will need to handle that
    - what if the Get ReceiptLines() function is called: in that case your first line will be a textline referring to a the first receipt on the invoice.
    - what if the first line is just a comment, and not a 'real' line: bottomline question: what do you consisder to be the first line?
     
    The only workable solution in my opinion is to determine the 'first line' in the Release() or Request Approval(depening on your setup) events.
    That of course will override the manual input the user has given.
     
    so I leave you with 2 questions:
    - what do you call the first line
    - how much work do you want to spend on coding the housekeeping for this?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans