Dynamics 365 Business Central is a powerful Enterprise Resource Planning (ERP) solution that offers a wide range of customization options to meet the unique needs of your business. One such customization is to get linked Sales order’s data in Assembly Order. This customization can be used for businesses that deal with complex assembly processes and require visibility into the sales orders associated with assembly orders.
We recently encountered a requirement where we need to retrieve linked sales order data in assembly order. The objective was to enable users to effortlessly access relevant sales order information directly from the assembly order.
In Microsoft Dynamics Business Central, to Retrieve Linked Sales Order Data in Assembly Orders, follow these implementation steps:
Step 1: Create a TableExtension and Add Fields:
Create a table extension for the Assembly Order table and add fields to it to store the linked sales order data as shown in code below.
tableextension 90102 VAS_Assembly_Order extends "Assembly Header" { fields { field(90100; "Sales Order No"; Code[20]) { DataClassification = ToBeClassified; } field(90101; "Customer No"; Code[20]) { DataClassification = ToBeClassified; } field(90102; "Customer Name"; Text[2048]) { DataClassification = ToBeClassified; } } }
Step 2: Create a PageExtension and Add Fields:
After adding fields to the table extension, you need to create a page extension to display these fields on the Assembly Order page.
pageextension 90111 VAS_Assembly_Order extends "Assembly Order" { layout { addafter(Status) { field("Sales Order No"; Rec."Sales Order No") { ApplicationArea = All; Editable = false; trigger OnDrillDown() var myInt: Integer; begin Rec.ShowAsmToOrder(); end; } field("Customer No"; Rec."Customer No") { ApplicationArea = All; Editable = false; } field("Customer Name"; Rec."Customer Name") { ApplicationArea = All; Editable = false; } } } }
Step 3: Populate Data into these fields from the linked Sales Order:
Use the OnAfterGetRecord trigger to fetch data from the Sales Order linked to the Assembly Order and populate the fields accordingly. This trigger is executed after a record is retrieved from the database.
Declaration of Variables:
Condition Check:
Assemble-to-Order Link Retrieval:
Sales Order No. Assignment:
Customer Information Retrieval:
Record Modification:
pageextension 90111 VAS_Assembly_Order extends "Assembly Order" { layout { addafter(Status) { field("Sales Order No"; Rec."Sales Order No") { ApplicationArea = All; Editable = false; trigger OnDrillDown() var myInt: Integer; begin Rec.ShowAsmToOrder(); end; } field("Customer No"; Rec."Customer No") { ApplicationArea = All; Editable = false; } field("Customer Name"; Rec."Customer Name") { ApplicationArea = All; Editable = false; } } } trigger OnAfterGetRecord() var ATOLink: Record "Assemble-to-Order Link"; SalesHeader: Record "Sales Header"; begin if Rec."Assemble to Order" = true then begin ATOLink.Reset(); ATOLink.SetRange("Assembly Document Type", Rec."Document Type"); ATOLink.SetRange("Assembly Document No.", Rec."No."); if ATOLink.FindSet() then begin Rec."Sales Order No" := ATOLink."Document No."; SalesHeader.Reset(); SalesHeader.SetRange("Document Type", Rec."Document Type"); SalesHeader.SetRange("No.", ATOLink."Document No."); if SalesHeader.FindSet() then begin Rec."Customer No" := SalesHeader."Sell-to Customer No."; Rec."Customer Name" := SalesHeader."Sell-to Customer Name"; end; Rec.Modify(true); end; end; end; }
Step 4: Publish and Install the Extension
After creating the custom report, you’ll need to publish and install the extension in your Dynamics 365 Business Central instance.
Step 5: Test the Customization
Test the customization thoroughly to ensure it works as expected and meets your business requirements
In conclusion, this is one of the Dynamics 365 Business Central Solutions demonstrates a streamlined approach to retrieving linked sales order data within assembly orders in Business Central. By leveraging AL code and customization capabilities, businesses can efficiently integrate sales order information into their assembly processes, enhancing visibility and facilitating informed decision-making. This customization empowers users to navigate complex assembly workflows with ease, ultimately optimizing operational efficiency and driving business success.
This is just among the many solutions that Inkey IT Solutions Pvt. Ltd. can provide for all your Business Central related needs.
© All Rights Reserved. Inkey IT Solutions Pvt. Ltd. 2024
Leave a Reply