I have the following PXDBCalced field added to CustomerExt:
public abstract class isParent : PX.Data.BQL.BqlBool.Field<isParent> { }
[PXBool]
[PXUIField(DisplayName = "Is Parent")]
[PXDBCalced(typeof(IIf<
Exists<Select<BAccount,
Where<BAccount.parentBAccountID, Equal<Customer.bAccountID>>>>,
True, False>), typeof(bool))]
public virtual bool? IsParent { get; set; }
Then using this in PXRestrictor in SOInvoiceExt graph extension:
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXRestrictor(
typeof(Where<CustomerExt.isParent, Equal<False>>),
"Account cannot be selected because it is a parent account.",
typeof(Customer.acctCD))]
protected void _(Events.CacheAttached<ARInvoice.customerID> e)
{
}
Which actually works and prevents selecting a parent customer on this type of document (need to add this to a handful of other graphs as well, some which bind to BAccountId and not Customer Id, but I digress)
Although this “works” it breaks customer maintenance (AR303000) with a stack overflow. I assume there is a circular reference but not sure why it works in SOInvoiceEntry CustomerID and it also works in Customer GI if I add this field as a column in the grid results.
Any ideas how else I can implement this so as not to break AR303000?