We are creating a sales order from a job planning line using AL code, the goal is to make the warehouse shipment process from the orders, based on information stored in the jobs, this is our code.
pageextension 50121 SOfromJobPlanning extends "Job Planning Lines"
{
layout
{
// Add changes to page layout here
}
actions
{
// Add changes to page actions here
addlast(processing)
{
group("Create a Sales Order")
{
action("Sales Order")
{
ApplicationArea = All;
trigger OnAction()
var
"Sales Ord": Record "Sales Header"; // Tabla Sales Order
"Sales Line": Record "Sales Line"; // Tabla Sales Lines
Customer: Record Customer; // Tabla Customer
Jobs: Record Job; // Tabla Jobs
SOExist: Record "Sales Header";
SOpage: Page "Sales Order List";
Items: Record Item; // Tabla de Items
NextLineNo: Integer;
begin
Jobs.Get(Rec."Job No.");
Customer.Get(Jobs."Bill-to Customer No.");
"Sales Ord".Init();
"Sales Ord"."Document Type" := "Sales Ord"."Document Type"::Order;
"Sales Ord"."No." := '';
"Sales Ord"."Sell-to Customer No." := Customer."No.";
"Sales Ord"."Sell-to Customer Name" := Customer."Name";
"Sales Ord".Insert(TRUE);
"Sales Ord".JOB := Rec."Job No.";
"Sales Ord"."JOB TASK" := Rec."Job Task No.";
"Sales Ord"."Posting Date" := Rec."Planning Date";
"Sales Ord".Modify(TRUE);
//Sales Lines
"Sales Line".Init(); // Inicializa Sales Lines
"Sales Line"."Document Type" := "Sales Ord"."Document Type"::Order; //
"Sales Line"."Sell-to Customer No." := Customer."No.";
"Sales Line"."Document No." := "Sales Ord"."No.";
NextLineNo := NextLineNo + 10000;
"Sales Line"."Line No." := NextLineNo;
"Sales Line".Insert(true);
"Sales Line".Type := "Sales Line".Type::Item;
"Sales Line"."No." := Rec."No.";
"Sales Line".Description := Rec.Description;
"Sales Line"."Location Code" := Rec."Location Code";
"Sales Line"."Bin Code" := Rec."Bin Code";
"Sales Line".Quantity := Rec.Quantity;
"Sales Line"."Unit of Measure Code" := 'HARDWARE';
"Sales Line"."Unit Price" := Rec."Unit Cost";
"Sales Line"."Tax Area Code" := 'AVATAX';
"Sales Line"."Tax Group Code" := 'TAXABLE';
"Sales Line"."Line Amount" := Rec."Unit Cost";
"Sales Line"."Shipment Date" := Rec."Planning Date";
"Sales Line".Modify(true);
end;
}
}
}
}
var
myInt: Integer;
}
At the moment of executing the code the sales order is created in business central with the data of the job planning line, the sales order is put in release status and when we choose the option to create the warehuse shipment the following error appears.
Hi, Please check a few settings below.
Check the Require Shipemnt setting in the Location Card.
Check the Warehouse Employees.
Check the Location Code in the Sales Lines.
Then release the order, and the Warehouse Shipment can be created.
Hope this helps.
Thanks.
ZHU
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,900 Super User 2024 Season 2
Martin Dráb 229,275 Most Valuable Professional
nmaenpaa 101,156