I'm using the userLoginType and the userRoles to enable/disable some fields in my Row_Selected events, but using Acuminator https://github.com/Acumatica/Acuminator I get the PX1049 warning : https://github.com/Acumatica/Acuminator/blob/dev/docs/diagnostics/PX1049.md
my code is the following :
public class OpportunityMaintExt : PXGraphExtension<OpportunityMaint>
{
public PXSelectJoin<EPLoginType, InnerJoin<Users, On<Users.loginTypeID, Equal<EPLoginType.loginTypeID>>>,
Where<Users.pKID, Equal<Current<AccessInfo.userID>>>> userLoginType;
public PXSelect<Contact, Where<Contact.userID, Equal<Current<AccessInfo.userID>>>> userContact;
public PXSelect<UsersInRoles, Where<UsersInRoles.username, Equal<Current<AccessInfo.userName>>>> userRoles;
public string userLoginTypeName;
protected virtual void CROpportunity_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
CROpportunity o = e.Row as CROpportunity;
CROpportunityExt myOpp = sender.GetExtension<CROpportunityExt>(sender.Current);
userLoginTypeName = TRLoginInfo.getCurrentUserLoginType(userLoginType.SelectSingle(), userRoles);
enabledisablefields();
}
The problem is with the userLoginType.SelectSingle(), the Acuminator tells me that : "In Rowselected Handler, bql and databasequeries should be avoided". But If I place this in Initialize() it gives the same warning.
So, where am I supposed to put these bql/database queries If I want them to be processed when I watch a record ?
Thanks a lot !
Ideally - you should fire your BQL in the RowSelecting Event within a new PXConnectionScope (BQL within RowSelecting Events MUST be done within a new PXConnectionScope to prevent issues), assign non-db-backed fields within your DAC Extension, then use their values in your RowSelected Event to determine whether or not certain fields should be enabled.