Hi All
I have created a page action to create an Assembly order from job lines but when I VALIDATE quantity on Assembly order it comes up with the famous RUN MODEL error and pop (when components are not enough ). Tried COMMIT before but didn't work
codeunit 10010 MY_AssemblyOrderCreateFromJob
{
trigger OnRun()
begin
end;
//pass rec from planning line page action
procedure MY_CreateAssemblyHeader(JobPlanningLine: Record "Job Planning Line")
var
IsHandled: Boolean;
//guiallowed: Boolean;
AssemblyHeader: Record "Assembly Header";
begin
Clear(AssemblyHeader);
AssemblyHeader.Init();
AssemblyHeader.Validate("Document Type", AssemblyHeader."Document Type"::Order);
AssemblyHeader.Insert(true);
AssemblyHeader.Validate("Item No.", JobPlanningLine."No.");
AssemblyHeader.Validate("Variant Code", JobPlanningLine."Variant Code");
AssemblyHeader.VALIDATE(Quantity,JobPlanningLine.Quantity);
AssemblyHeader.Validate("Due Date", JobPlanningLine."Planning Date");
AssemblyHeader.Validate(MY_JobNo, JobPlanningLine."Job No.");
AssemblyHeader.Validate(MY_JobTaskNo, JobPlanningLine."Job Task No.");
AssemblyHeader.Validate(MY_JobPlanningLineNo, JobPlanningLine."Line No.");
AssemblyHeader.Modify();
if AssemblyHeader.Modify(true) then
Message('Assembly Order Created. Use link under Proces to navigate');
end;
0
Answers
If NOT GuiAllowed Then ConfirmProcess
as discussed here:
https://community.dynamics.com/nav/b/mynavblog/posts/how-to-write-error-and-confirm