There are a few ways you can handle this depending on how strict you want the restriction to be.
If you simply want to prevent the user from editing the Branch field under certain conditions, you can control it at the UI level in the graph using RowSelected:
throw new PXSetPropertyException("Branch cannot be changed under current conditions.");
}
}
That ensures the change is blocked at the business logic level.
If the restriction is role-based rather than condition-based, you may also want to consider access rights or branch restrictions at the user role level instead of customization.
So the best approach depends on:
Is this purely UI behavior?
Or must it be enforced at system level?
For critical controls, I would recommend using FieldVerifying to ensure it cannot be bypassed.
Thanks for clarifying — since you're referring to the system branch selector in the top-right corner (the branch context switch), that isn’t something that should be controlled via customization code.
The branch dropdown is driven by user access rights and branch restrictions. If you want to prevent a user from switching to certain branches, you should configure:
The branches assigned to the user
Role-based access rights
Branch access settings under Users (SM201010)
A user can only switch to branches they have access to. So the proper way to restrict this is by adjusting branch access/security configuration rather than writing customization logic.
If your requirement is conditional (for example, prevent switching branches only under certain transaction states), that would be more complex and would typically require reviewing the business process, since the branch selector is designed as a system-level context control.
Understood. Since you specifically want to control this through customization, the important thing to know is that the branch selector in the header changes the system context (AccessInfo.BranchID) and refreshes the session. It is not a normal DAC field, so there isn’t a direct event that fires when the user clicks the branch dropdown.
Because of that, you generally cannot “disable” the branch selector itself in a clean, supported way through customization.
What you can do is enforce your business rule at the graph level.
If you simply want to prevent the user from editing the Branch field under certain conditions, you can control it at the UI level in the graph using RowSelected:
throw new PXSetPropertyException("Branch cannot be changed under current conditions.");
}
}
That ensures the change is blocked at the business logic level.
If the restriction is role-based rather than condition-based, you may also want to consider access rights or branch restrictions at the user role level instead of customization.
So the best approach depends on:
Is this purely UI behavior?
Or must it be enforced at system level?
For critical controls, I would recommend using FieldVerifying to ensure it cannot be bypassed. By this way you can restrict the Branch change through customization level.
2] Way (Through Website itself)
The branch dropdown is driven by user access rights and branch restrictions. If you want to prevent a user from switching to certain branches, you should configure:
The branches assigned to the user
Role-based access rights
Branch access settings under Users (SM201010)
A user can only switch to branches they have access to. So the proper way to restrict this is by adjusting branch access/security configuration rather than writing customization logic.
If your requirement is conditional (for example, prevent switching branches only under certain transaction states), that would be more complex and would typically require reviewing the business process, since the branch selector is designed as a system-level context control.
By this you can restrict a specific role to change the branch
If you want any specific condition for branch changing restriction then please let me know.
@aryanjadhav50 What is the DAC of the Acumatica system BranchID? Why can this code disable the main Branch dropdown in Acumatica? PXUIFieldAttribute.SetEnabled<YourDAC.branchID>(e.Cache, e.Row, !restrict);
if (disableBranch) { PXUIFieldAttribute.SetEnabled(e.Cache, e.Row, false); } } } }
What this code does
Runs when any screen loads
Detects the Branch selector
Makes it read-only
User can see the branch
User cannot change it
No error messages, no popups — just locked.
STEP 3 — Publish the customization
Save the customization project
Publish
Log in as a normal user
Open any screen
Try changing Branch → it will be disabled
Important notes (real-world behavior)
This is UI-only
It does not replace branch security
Admin users will also see it locked unless excluded
Works across all screens consistently
Optional: Exclude Admin users
If you want admins to still change branches, modify the code:
if (PXAccess.GetUserName() == "admin") return;
Add that check before disabling the field.
Look like this you can make the branch readonly so the users are restricted to change branch but have access of warehouse. Please let me know any specific condition was there.
@aryanjadhav50Thank you for your answer. This does not work for me. I tried this, but the function is not being called. I tried to debug it, and it doesn’t enter this function.
public class BranchSelectorDisabler : PXGraphExtension<PXGraph> { protected void _(Events.RowSelected<Branch> e) { if (e.Row == null) return;