Hi All,
I want to show all records associated with any Account when Account Filter field is null in Account Details Screen. Otherwise it should work as usual. How can I achieve this?
Thanks
Hi All,
I want to show all records associated with any Account when Account Filter field is null in Account Details Screen. Otherwise it should work as usual. How can I achieve this?
Thanks
Best answer by davidnavasardyan
Hi
To achieve this functionality, you can modify the BQL Select statement of the view associated with the Account Details grid in the graph extension. You can use the Where method and If BQL statement to handle the case when the Account Filter field is null and when it is not. Below is an example of how you can achieve this:
Assuming you have a DAC called AccountDetail and the graph associated with the Account Details Screen is AccountDetailsGraph. Also, let's assume that the AccountFilter field is part of a DAC called AccountFilter.
Here's how you can create a graph extension to modify the behavior of the view:
public class AccountDetailsGraph_Extension : PXGraphExtension<AccountDetailsGraph>
{
// Assuming your original view is called AccountDetails
public PXSelect<AccountDetail,
Where2<Where<AccountFilter.accountID, IsNull,
Or<AccountDetail.accountID, Equal<Current<AccountFilter.accountID>>>>,
And<... /* other conditions here */>>> AccountDetails;
protected virtual void _(Events.RowSelected<AccountFilter> e)
{
if (e.Row == null) return;
AccountDetails.View.WhereAnd<Where<AccountDetail.accountID, Equal<Current<AccountFilter.accountID>>>>();
if (e.Row.AccountID == null)
{
AccountDetails.View.WhereOr<Where<AccountDetail.accountID, IsNotNull>>();
}
}
}In the code above, we're extending the AccountDetailsGraph and modifying the AccountDetails view's BQL statement. In the RowSelected event of the AccountFilter DAC, we're checking if the AccountID is null. If it is, we modify the view to show all records where AccountID is not null. Otherwise, it will only show records associated with the selected Account ID.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.