Job.Validate("Global Dimension 1 Code", SalesHeader."Shortcut Dimension 1 Code"); Job.Validate("Global Dimension 2 Code", SalesHeader."Shortcut Dimension 2 Code");
local procedure UpdateJobTaskDimension(FieldNumber: Integer; ShortcutDimCode: Code[20]) var JobTask: Record "Job Task"; IsHandled: Boolean; begin IsHandled := false; OnBeforeUpdateJobTaskDimension(Rec, FieldNumber, ShortcutDimCode, IsHandled); if IsHandled then exit; if GuiAllowed then if not Confirm(UpdateJobTaskDimQst, false) then exit; JobTask.SetRange("Job No.", "No."); if JobTask.FindSet(true) then repeat case FieldNumber of 1: JobTask.Validate("Global Dimension 1 Code", ShortcutDimCode); 2: JobTask.Validate("Global Dimension 2 Code", ShortcutDimCode); end; JobTask.Modify(); until JobTask.Next() = 0; end;
Answers
RIS Plus, LLC
Not sure what you mean by ‘something better’, it is what it is. You’re lucky that this function has an IsHandled flag, not all of them do
RIS Plus, LLC
This won't show any messages, confirms, etc.
True, because that starts a background session, and GuiAllowed is false there. However it also starts a new and independent transaction and I'm not sure if that is a good idea for a simple field validation. Those background sessions are supposed to be background tasks, I would not use them like this
RIS Plus, LLC