Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Answered

Get Sales Shipment Header during Invoice posting

Posted on by 2,983

When posting an Sales invoice, is there any way we can get the Sales Shipment No. ? We have created a custom field in "Sales invoice header", "Shipment No.";

When a user posts a sales Order with "Ship and invoice" option, we want to save the shipment number in this new field. The problem is, I can't find an event where I have the Shipment No. available.

My idea was to use the OnBeforeSalesInvHeaderInsert Event in CU 80, but I don't have the Shipment No. here.

LOCAL [EventSubscriber] OnBeforeSalesInvHeaderInsert(VAR SalesInvHeader : Record "Sales Invoice Header";SalesHeader : Record "Sales Header";CommitIsSuppressed : Boolean) 

Any ideas?

Categories:
  • Anita75 Profile Picture
    Anita75 1,159 on at
    RE: Get Sales Shipment Header during Invoice posting

    thanks but Didn't work in 17.2 version and got this error though using "SUPER" permission set:

    You do not have the following permissions on TableData Sales Invoice Header: Modify.

    Logically you cannot modify posted invoice?

  • Andy Sather Profile Picture
    Andy Sather on at
    RE: Get Sales Shipment Header during Invoice posting

    Thank you for posting your solution

  • Suggested answer
    Ghetz Profile Picture
    Ghetz 2,983 on at
    RE: Get Sales Shipment Header during Invoice posting

    OK. In case it helps someone, I finally used a different trigger from CU80

    LOCAL [EventSubscriber] OnAfterPostSalesLines(VAR SalesHeader : Record "Sales Header";VAR SalesShipmentHeader : Record "Sales Shipment Header";VAR SalesInvoiceHeader : Record "Sales Invoice Header";VAR SalesCrMemoHeader : Record "Sales Cr.Memo Header";VAR ReturnReceiptHeader : Record "Return Receipt Header";WhseShip : Boolean;WhseReceive : Boolean;VAR SalesLinesProcessed : Boolean;CommitIsSuppressed : Boolean;EverythingInvoiced : Boolean)

    IF SalesHeader.Ship THEN

     SalesInvoiceHeader."Custom Field" := SalesShipmentHeader."No.";

     SalesInvoiceHeader.MODIFY;

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

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,339 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,177 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans