RE: Making an option Field mandatory and not letting user create a job Planning line
Sharing My Code:
Table.Ext
trigger OnBeforeInsert()
begin
if JPLMgmt.AssignObjectId() = 'Page Job Planning Lines' then begin
if Rec."WCI Job Posting Group" = '' then begin
Rec.TestField(Rec."WCI Job Posting Group");
end;
end;
end;
Page.Ext Code:
trigger OnAfterGetCurrRecord()
begin
ObjectId := (CurrPage.ObjectId(true));
if ObjectId = 'Page Job Planning Lines' then begin
JPLMgmt.SetObjectId(ObjectId);
end;
end;
trigger OnClosePage()
begin
ObjectId := '';
JPLMgmt.SetObjectId(ObjectId);
end;
CodeUnit Code:
procedure SetObjectId(var ObjectId: Text): Text
begin
if ObjectId = 'Page Job Planning Lines' then begin
ObjectIdP := ObjectId;
end
else begin
ObjectId := '';
ObjectIdP := ObjectId;
end;
exit(ObjectIdP);
end;
procedure AssignObjectId(): Text
begin
ObjectIdP := ObjectIdP;
exit(ObjectIdP);
end;
The issue with this is when editing in excel the job Group is not considered mandatory, the user can save values without entering the Job Posting Group.
trigger OnValidate cannot be used for existing fields.
Does OnAfterValidate work?