web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

AL Code: Transfer Field From Sales Shipment To Service Item

(2) ShareShare
ReportReport
Posted on by 3,176
Hi All
Is there a way to transfer a field from sales shipment Header or line to Service Item that gets created automatically when shipping items with service item group? What is is the event we can subscribe to?
I have the same question (0)
  • Suggested answer
    Sagar Dangar, MCP Profile Picture
    783 Super User 2025 Season 2 on at
    AL Code: Transfer Field From Sales Shipment To Service Item
    Hi,
     
    You can add your AL code onvalidate() trigger of that field
  • Suggested answer
    Sagar Dangar, MCP Profile Picture
    783 Super User 2025 Season 2 on at
    AL Code: Transfer Field From Sales Shipment To Service Item
    tableextension 50104 "Sales Shipment Line" extends "Sales Shipment Line"
    {
        fields
        {
            // Add changes to table fields here
            field(50100; "Logistic Name"; Text[100])
            {
                DataClassification = ToBeClassified;
                trigger OnValidate()
                var
                    Item: Record Item;
                begin
                    if Item.Get(Rec."No.") then begin
                        Item.validate("logistic Name", Rec."Logistic Name");
                        Item.Modify(true);
                    end;
     
                end;
            }
        }
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    19,139 Super User 2025 Season 2 on at
    AL Code: Transfer Field From Sales Shipment To Service Item
  • Verified answer
    Sohail Ahmed Profile Picture
    11,087 Super User 2025 Season 2 on at
    AL Code: Transfer Field From Sales Shipment To Service Item
    // Assume you have a custom field 'YourCustomField' added to Sales Shipment Line and Service Item
    
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Service Item Management", 'OnBeforeCreateServiceItem', '', false, false)]
    local procedure OnBeforeCreateServiceItemFromShipment(
        var NewServiceItem: Record "Service Item";
        SalesShipmentLine: Record "Sales Shipment Line";
        SalesLine: Record "Sales Line";
        Item: Record Item;
        Customer: Record Customer;
        ShipToAddress: Record "Ship-to Address";
        ServiceItemGroup: Record "Service Item Group";
        ItemTracking: Boolean;
        var IsHandled: Boolean)
    begin
        // Example: Transfer custom field value from Shipment Line to Service Item
        NewServiceItem."YourCustomField" := SalesShipmentLine."YourCustomField";
    end;
    
     
     
     

    Mark below checkbox to make this answer Verified if it helps you.

     
  • Suggested answer
    YUN ZHU Profile Picture
    92,656 Super User 2025 Season 2 on at
    AL Code: Transfer Field From Sales Shipment To Service Item
    Hi, Try the following event, which contains var ServiceHeader: Record "Service Header"; ServShipmentNo: Code[20]; ServInvoiceNo: Code[20]
     
     OnAfterPostServiceDoc(ServiceHeader, ServShipmentNo, ServInvoiceNo, ServCrMemoNo, ServDocumentsMgt, SuppressCommit, PassedShip, PassedConsume, PassedInvoice, WhseShip);
     
    Hope this helps.
    Thanks.
    ZHU
  • Suggested answer
    RockwithNav Profile Picture
    8,335 Super User 2025 Season 2 on at
    AL Code: Transfer Field From Sales Shipment To Service Item
    Event is the only solution as we are aware since Business central inception, several events we have but I will urge you to explore this looking at the codebase and decide which one is most suitable for you.  :)

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 4,232

#2
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 2,863

#3
Sumit Singh Profile Picture

Sumit Singh 2,819

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans