I guess this may require a customisation. Is it possible to restrict Shipping Rule in a sales order (making it read-only) if the Term of that order is X only for people who have user role Y?
Answer
Restrict a field based on value on another field
Best answer by aiwan
Hi
Yes, this will be a customisation.
You could configure the field via access rights, but I am not sure of the interactions that would occur if you are trying to control via access rights for the user role, and based on the shipping role via code.
You could use a method like below:
public static bool IsUserRole(string roleName, PXGraph graph)
{
string usrName = graph.Accessinfo.UserName;
UsersInRoles assignedRoles = SelectFrom<UsersInRoles>.
Where<UsersInRoles.username.IsEqual<P.AsString>.
And<UsersInRoles.rolename.IsEqual<P.AsString>>>.View.Select(graph, usrName, roleName);
if (assignedRoles == null)
return false;
else
{
if(graph.YourView.Current.ShippingRule == "YourShippingRule")
return true;
}
return false;
}Then implement this like so:
PXUIFieldAttribute.SetVisible<YourDAC.yourField>(e.Cache, row, IsUserRole("Administrator", this));Hope this helps!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.