Skip to main content

I am pulling data from a table based on a PXFilter.  One parameter of the Where clause is to pull based on the current logged in User ID.  I created a public variable _currentUser that holds the User ID.

public Guid? _currentUser = CommonServiceLocator.ServiceLocator.Current.GetInstance<ICurrentUserInformationProvider>().GetUserId();

How can I pass that value into the Select for the View?  If I put an @P parameter, it compiles.  If I try to use a View.Select(this, _currentUser) to pass in the parameter, I get all kinds of errors. I can’t pass in the actual _currentUser variable because I think it needs to be a type, not a value.

public SelectFrom<QTCAuditHistoryReport>.			Where<QTCAuditHistoryReport.screenID.IsEqual<QTCAuditHistoryReportFilter.screenID.FromCurrent>.
And<QTCAuditHistoryReport.changeDate.IsEqual<QTCAuditHistoryReportFilter.changeDate.FromCurrent>.
And<QTCAuditHistoryReport.reportingUserid.IsEqual<@P.AsGuid>>>>.View.ReadOnly DetailsView;

I think this option would be best but I’m not sure how to do it.

I tried adding the UserID field to the Filter (invisible) so I could just use QTCAuditHistoryReportFilter.userID.FromCurrent.  How would I set the value of a BQL table in the filter to be the UserID?  

 

Hi @joe21 

you can try with accessInfo.UserID.


public SelectFrom<QTCAuditHistoryReport>.Where<QTCAuditHistoryReport.screenID.IsEqual<QTCAuditHistoryReportFilter.screenID.FromCurrent>. And<QTCAuditHistoryReport.changeDate.IsEqual<QTCAuditHistoryReportFilter.changeDate.FromCurrent>.And<QTCAuditHistoryReport.reportingUserid.IsEqual<Current<AccessInfo.userID>>>>>.View.ReadOnly DetailsView;


Hey @joe21  Try this!!

 SelectFrom<QTCAuditHistoryReport>.Where<QTCAuditHistoryReport.screenID.IsEqual<QTCAuditHistoryReportFilter.screenID.FromCurrent>.
            And<QTCAuditHistoryReport.changeDate.IsEqual<QTCAuditHistoryReportFilter.changeDate.FromCurrent>.
                And<QTCAuditHistoryReport.reportingUserid.IsEqual<AccessInfo.userID.FromCurrent>>>>.View.ReadOnly DetailsView;


@Naveen Boga , that worked.  

@jinin , just missing the FromCurrent.   SO CLOSE! :-)

THANK YOU BOTH!


I don’t think I should be using PXFilter on this form.  Let me try redoing the graph to just be a simple Form/Details not using PXFilter. 

Either way, I’d like to be able to supply the UserID to the SelectFrom.  


Hi @jinin 

When I put that in the select, I get a red squiggle on the statement saying that it can’t implicitly convert Guid to IBqlGuid

I’m not too savvy with C#.  I tried to cast it (not sure if this syntax is even correct)

<(IBqlGuid)Current<AccessInfo.userID» 

but that doesn’t compile.  Seems closer to the answer though!  Thank you for assisting!


Reply