Hi All,
I got a requirement like, client wants Unit Cost and Unit Cost(LCY) visible according to user setup, also ‘Unit Price’ should be visible and editable according to user setup wise on Sales Order. For it I have created three fields in User Setup table, “Unit Cost Visible”, “Unit Price Visible”, “Unit Price Editable”
and wrote below code:
pageextension 50007 SOSubFormExt extends “Sales Order Subform”
{
layout
{
modify(“Unit Cost (LCY)”)
{
Visible = UnitCostIsVisible;
Editable = false;
}
modify(“Unit Price”)
{
Visible = UnitPriceIsVisible;
Editable = UnitPriceIsEditable;
}
modify(“Line Amount”)
{
Visible = UnitPriceIsVisible;
Editable = UnitPriceIsEditable;
}
addafter(“Unit Cost (LCY)”)
{
field(“Unit Cost”; “Unit Cost”)
{
Visible = UnitCostIsVisible;
Editable = false;
ApplicationArea = All;
}
}
}
actions { }
trigger OnOpenPage()
var
myInt: Integer;
begin
if UserSetup.Get(UserId) then begin
if UserSetup.“Unit Cost Visible” = true then begin
UnitCostIsVisible := true
end else begin
UnitCostIsVisible := false;
end;
if UserSetup.“Unit Price Visible” = false then begin
UnitPriceIsVisible := false;
UnitPriceIsEditable := false;
end else
if UserSetup.“Unit Price Editable” = true then begin
UnitPriceIsEditable := true;
UnitPriceIsVisible := true;
end else begin
UnitPriceIsVisible := true;
UnitPriceIsEditable := false;
end;
end;
end;
trigger OnAfterGetRecord()
var
myInt: Integer;
begin
UnitCostIsVisible := false;
UnitPriceIsVisible := false;
UnitPriceIsEditable := false;
if UserSetup.Get(UserId) then begin
if UserSetup.“Unit Cost Visible” = true then begin
UnitCostIsVisible := true
end else begin
UnitCostIsVisible := false;
end;
if UserSetup.“Unit Price Visible” = false then begin
UnitPriceIsVisible := false;
UnitPriceIsEditable := false;
end else
if UserSetup.“Unit Price Editable” = true then begin
UnitPriceIsEditable := true;
UnitPriceIsVisible := true;
end else begin
UnitPriceIsVisible := true;
UnitPriceIsEditable := false;
end;
end;
end;
var
UserSetup: Record “User Setup”;
UnitPriceIsEditable: Boolean;
UnitCostIsVisible: Boolean;
UnitPriceIsVisible: Boolean;
}
It is working fine in Sandbox but in Production even if “Unit Cost Visible” is False still Unit Cost(LCY) is visible on page whare as Unit Cost is not visible.
Where and what I am doing wrong?
Thanks in Advance.