Good day, everyone.
We customized a requisition (RQ302000) screen Ref Nbr. Selector to load data based on a logged in user's user role.
The selector worked fine when there were few records, but now we have thousands of records and every field on the screen takes time to update the value because of this custom selector.
The code for the custom selector is shown below. What is the best way to avoid this performance problem, and what changes should we make to this custom selector?
public class RequisitionEntryRQNbrExt : PXGraphExtension<RQRequisitionEntry>
{
#region Ref nbr attribute override
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXRemoveBaseAttribute(typeof(PXSelectorAttribute))]
[RQRequisitionRestrictExt]
protected virtual void RQRequisition_ReqNbr_CacheAttached(PXCache cache)
{
}
public class RQRequisitionRestrictExt : PXCustomSelectorAttribute
{
public RQRequisitionRestrictExt()
: base(typeof(RQRequisition.reqNbr))
{
this.DescriptionField = typeof(RQRequisition.description);
}
protected virtual IEnumerable GetRecords()
{
var graph = this._Graph;
//PXCache cache = null;
//if (graph != null)
//{
// cache = _Graph.GetPrimaryCache();
//}
//if (cache == null)
//{
// yield break;
//}
UsersInRoles roleaccess = PXSelect<
UsersInRoles,
Where2<
Where<UsersInRoles.username, Equal<Required<AccessInfo.userName>>>,
And<Where<UsersInRoles.rolename, Equal<Required<UsersInRoles.rolename>>,
Or<UsersInRoles.rolename, Equal<Required<UsersInRoles.rolename>>,
Or<UsersInRoles.rolename, Equal<Required<UsersInRoles.rolename>>,
Or<UsersInRoles.rolename, Equal<Required<UsersInRoles.rolename>>
>>>>>>>
.Select(graph, graph.Accessinfo.UserName, "Administrator", "POAdmin", "POManager", "RQAdmin");
if (roleaccess != null)
{
foreach (PXResult<RQRequisition, Customer, Vendor> result in PXSelectReadonly2<RQRequisition,
LeftJoinSingleTable<Customer, On<Customer.bAccountID, Equal<RQRequisition.customerID>>,
LeftJoinSingleTable<Vendor, On<Vendor.bAccountID, Equal<RQRequisition.vendorID>>>>,
Where2<Where<Customer.bAccountID, IsNull,
Or<Match<Customer, Current<AccessInfo.userName>>>>,
And<Where<Vendor.bAccountID, IsNull,
Or<Match<Vendor, Current<AccessInfo.userName>>>>>>>.Select(graph))
{
yield return result;
}
}
else
{
EPEmployee employeeDetail = PXSelect<EPEmployee, Where<EPEmployee.userID, Equal<Required<EPEmployee.userID>>>>.Select(this._Graph, this._Graph.Accessinfo.UserID);
if (employeeDetail != null)
{
foreach (PXResult<RQRequisition, Customer, Vendor> result in PXSelectReadonly2<RQRequisition,
LeftJoinSingleTable<Customer,
On<Customer.bAccountID, Equal<RQRequisition.customerID>>,
LeftJoinSingleTable<Vendor,
On<Vendor.bAccountID, Equal<RQRequisition.vendorID>>>>,
Where2<Where<Customer.bAccountID, IsNull,
Or<Match<Customer, Current<AccessInfo.userName>>>>,
And2<Where<Vendor.bAccountID, IsNull,
Or<Match<Vendor, Current<AccessInfo.userName>>>>,
And<Where<RQRequisition.employeeID, Equal<Required<RQRequisition.employeeID>>>>>>>
.Select(this._Graph, employeeDetail.BAccountID))
{
yield return result;
}
}
}
}
}
#endregion
}
Can anyone suggest the solution?
Thanks..