Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

which event or suscription must to modify "Posting No Series Code" field, in Sales header

Posted on by 74

Hi

I have two serial numbers (in No Series Relation ship)) to post my sales order (in setup posting invoice No), and I have the function that defines which series should be assigned for the order to be posted,
the question is which event or on which subscription should I call the procedure I create?

I am using an extention for Sales order card and put the procedure in the trigger modify Like this:

trigger OnModifyRecord()Boolean
    begin
        Rec."Posting No. Series" := DCLFunSalesCode.TypePosting(Rec."Sell-to Customer No.");
    end;
But I am not sure if I must to use in my codeunit somethig like. 

    [EventSubscriber(ObjectType::Tabledatabase::"Sales Header", 'OnAfterGetPostingNoSeriesCode''', false, false)]
    local procedure OnAfterGetPostingNoSeriesCode(SalesHeader: Record "Sales Header"; var PostingNos: Code[20])
    begin
        if SalesHeader."Sell-to Customer No." <> '' then
            SalesHeader."Posting No. Series" := TypePosting(SalesHeader."Sell-to Customer No.");
    end;
the problem is I can't see when is execute for this suscriber and with the trigger modify is calling when I close de page, and I need to be 
sure that the my procedure is executed before to be posted.
Categories:
  • Suggested answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,640 on at
    RE: which event or suscription must to modify "Posting No Series Code" field, in Sales header

    You can subscribe to the OnAfterInitRecord event in the table 36, where you can override posting no. series.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,246 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,041 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans