Solved

PXFilterProcessing selector pulling from a DateTime field


Userlevel 6
Badge +3

I have a processing screen that pulls records based on a date range.  

        public PXFilteredProcessing<AuditHistory, QTCAuditHistoryReportFilter, 
            Where<AuditHistory.screenID.IsEqual<QTCAuditHistoryReportFilter.screenID.FromCurrent>.
                And<AuditHistory.changeDate.IsBetween<QTCAuditHistoryReportFilter.startDate.FromCurrent, QTCAuditHistoryReportFilter.endDate.FromCurrent>>>> RecordsToProcess;
 

The filter screen looks like this.

 

The problem is that if there is a record in the AuditHistory table with a change date of

2022-07-06 21:44:08.583 it won’t get selected.  I need my selector to just look for the DATE portion and ignore the time portion.  

Is there something I can do in my selector to just use the Date portion?

icon

Best answer by Naveen Boga 6 July 2022, 19:34

View original

6 replies

Userlevel 6
Badge +4

Hi @joe21 

 

This article might help you dealing with Dates in BQL

 

https://stackoverflow.com/questions/27726383/does-bql-allow-for-datepart

 

 

Userlevel 7
Badge +17

Hi @joe21 To get those records, you can have a view delegate like below and verify.

 

 

 protected virtual IEnumerable recordsToProcess()
        {
            QTCAuditHistoryReportFilter filter = Filter.Current;
            if (filter != null && !string.IsNullOrEmpty(filter.ScreenID) && filter.StartDate != null && filter.EndDate != null)
            {
                PXSelectBase<AuditHistory> preparedorder = new PXSelect<AuditHistory, 
                                                      Where<AuditHistory.screenID, Equal<Required<AuditHistory.screenID>>,
                                                      And<AuditHistory.changeDate,GreaterEqual<Required<AuditHistory.changeDate>>,
                                                      And<AuditHistory.changeDate, Less<Required<AuditHistory.changeDate>>>>>>(this);
                return preparedorder.Select(filter.ScreenID, filter.StartDate, filter.EndDate.Value.AddDays(1).AddTicks(-1));

}
}


            

Userlevel 6
Badge +3

Hi @Naveen Boga 

I put the code in and it compiles.  How does this method get called?  I mean, how do I actually implement that?  If you get a chance, I have another topic where I’m trying to get my processing delegate to fire.

This code you provided would need to be part of that solution.  If you can look at that, I’d be much obliged.

 

Userlevel 6
Badge +4

Hi @joe21 

Acumatica handles IEnumerable by having methods with the same name as the view. In your case your processing view is RecordsToProcess. The respective view method is recordsToProcess (with lower case).

@Naveen Boga is also correct in proposing this approach as you can handle the data that is delivered when the view is invoked.

Userlevel 7
Badge +17

@joe21  View Delegates will be invoked for every action that is performed for the VIEW.

 

In this case, as soon as you select the FromDate/ToDate/Screen ID is selected on the screen, View Delegate will invoke and execute the BQL.

 

 

Userlevel 6
Badge +3

Thanks guys for the quick support.  Thanks @Naveen Boga  for the code (which works great!) and @Leonardo Justiniano  for explaining WHY it works!!  

 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved