How to stop Pop up when creating Assembly Order from Code

samantha73samantha73 Member Posts: 106
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;

Answers

Sign In or Register to comment.