
Hello All,
am new to BC and its my learning Stage. i request the kind help and considerations from the Experts
i created 4 custom fields, and once User is entered the data then it should disabled and Should be editable to one particular user only,
1st issue - allowing only to enter all the data together otherwise it get disabling. (It should not be like that, it should disable only which field is user confirming
2nd - if user enters last field 1st , it get disabling all the fields. it should separate for each fields
Kindly correct where i made the mistake in Code.
addafter("Project Manager")
{
field("Previous Year Cost"; Rec."Previous Year Cost")
{
ApplicationArea = all;
Editable = IsEditable;
Caption = 'Previous Year Cost';
trigger OnValidate()
var
myInt: Integer;
Confirm: Label 'You have added a Prev Yr Cost Amount %1 for the Job %2. It should not be editable once confirmed';
begin
If Rec."Previous Year Cost" <> 0.00 then begin
If not (UserId = 'ANUSUYA') then begin
If Dialog.Confirm(StrSubstNo(Confirm, Rec."Previous Year Cost", Rec."No."), false) then begin
CheckEditable();
CurrPage.Update();
end else
Rec."Previous Year Cost" := 0.00;
end;
end;
end;
}
}
addafter("Previous Year Cost")
{
field("Previous Year Invoice"; Rec."Previous Year Invoice")
{
ApplicationArea = all;
Editable = IsEditable;
Caption = 'Previous Year Invoice';
trigger OnValidate()
var
myInt: Integer;
Confirm: Label 'You have added a Prev Yr Inv Amount %1 for the Job %2. It should not be editable once confirmed';
begin
If Rec."Previous Year Invoice" <> 0.00 then begin
If not (UserId = 'ANUSUYA') then begin
If Dialog.Confirm(StrSubstNo(Confirm, Rec."Previous Year Invoice", Rec."No."), false) then begin
CheckEditable();
CurrPage.Update();
end else
Rec."Previous Year Invoice" := 0.00;
end;
end;
end;
}
}
addafter("Previous Year Invoice")
{
field("Project Cost"; Rec."Project Cost")
{
ApplicationArea = all;
Editable = IsEditable;
Caption = 'Project Revenue';
trigger OnValidate()
var
myInt: Integer;
Confirm: Label 'You have added a Cost Amount %1 for the Job %2. It should not be editable once confirmed';
begin
If Rec."Project Cost" <> 0.00 then begin
If not (UserId = 'ANUSUYA') then begin
If Dialog.Confirm(StrSubstNo(Confirm, Rec."Project Cost", Rec."No."), false) then begin
CheckEditable();
CurrPage.Update();
end else
Rec."Project Cost" := 0.00;
end;
end;
end;
}
}
addafter("Project Cost")
{
field("Project Expense"; Rec."Project Expense")
{
ApplicationArea = all;
Editable = IsEditable;
trigger OnValidate()
var
myInt: Integer;
Confirm: Label 'You have added a Expense Amount %1 for the Job %2. It should not be editable once confirmed';
begin
If Rec."Project Expense" <> 0.00 then begin
If not (UserId = 'ANUSUYA') then begin
If Dialog.Confirm(StrSubstNo(Confirm, Rec."Project Expense", Rec."No."), false) then begin
CheckEditable();
CurrPage.Update();
end else
Rec."Project Expense" := 0.00;
end;
end;
end;
}
}
}
var
[InDataset]
IsEditable: Boolean;
local procedure CheckEditable()
var
UserRec: Record "User Group Member";
begin
If Rec."Previous Year Cost" <> 0 then begin
If UserId = 'ANUSUYA' then
IsEditable := true
else
IsEditable := false;
end else
IsEditable := true;
If Rec."Previous Year Invoice" <> 0 then begin
If UserId = 'ANUSUYA' then
IsEditable := true
else
IsEditable := false;
end else
IsEditable := true;
If Rec."Project Cost" <> 0 then begin
If UserId = 'ANUSUYA' then
IsEditable := true
else
IsEditable := false;
end else
IsEditable := true;
If Rec."Project Expense" <> 0 then begin
If UserId = 'ANUSUYA' then
IsEditable := true
else
IsEditable := false;
end else
IsEditable := true;
end;
trigger OnAfterGetCurrRecord()
var
myInt: Integer;
begin
CheckEditable();
end;
trigger OnOpenPage()
var
myInt: Integer;
begin
CheckEditable();
end;
trigger OnAfterGetRecord()
var
myInt: Integer;
begin
CheckEditable();
end;
Kindly correct where i made the mistake in Code.
Regards