I have tried different methods for this case. I could change the lookup using an attribute, but for manual entry and for the Prev/Next/Last buttons, it doesn’t work. When I write e.NewValue = null or e.Cancel, or throw some exception in FieldUpdating/FieldVerifying, in some cases it returns an error, but the record still gets displayed. I tried using a Current Document delegate to change and add restrictions and also wrote a restriction attribute, but these options didn’t work either.
Solved
How to prevent selecting certain order numbers in Sales Order Entry using customization?
Best answer by darylbowman
Try this:
[PXViewName(Messages.SOOrder)]
[PXCopyPasteHiddenFields(typeof(SOOrder.showDiscountsTab))]
public SelectFrom<SOOrder>
.LeftJoin<Customer>
.On<SOOrder.customerID.IsEqual<Customer.bAccountID>>
.LeftJoin<UserPreferences>
.On<UserPreferences.userID.IsEqual<AccessInfo.userID.FromCurrent>>
.Where<SOOrder.orderType.IsEqual<Optional<SOOrder.orderType>>
.And<Customer.bAccountID.IsNull
.Or<Match<Customer, AccessInfo.userName.FromCurrent>>>
.And<SOOrder.branchID.IsEqual<UserPreferences.defBranchID>
.Or<UserPreferences.defBranchID.IsNull>>>.View Document;If you don’t already have it defined, you’ll need to add this ‘using’ statement:
using PX.Data.BQL.Fluent;
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.