Skip to main content

Hello,

 

I know using View.WhereAnd<> we can ammend the where statements and add a new condition like as i.e.

selectDetails.WhereAnd<Where<PMCostProjectionLine.taskID, Equal<Current<CostProjectionFilter.taskID>>>>();
  1. I was wondering is there a way to remove Where Condition(s) on the fly as well?
  2. Can we reset the Where statements added to the View Query on the fly to the default state before where statements amended?

Hi @aaghaei 

 

You can use query.WhereNew() to replace the filtering portion of the query.

selectDetails.WhereNew<Where<PMCostProjectionLine.taskID, IsNotNull>>();

Also, you could change the query through a view delegate.


@Leonardo Justiniano thank you. is it possible to remove the WhereAnd which is added on the fly? 


@aaghaei 

 

WhereNew will replace any filter added previously. 


Thank you @Leonardo Justiniano I tested this. WhereNew not only removes the conditions added on the fly but also removes the original conditions like as there was no condition from the begining. It is not what I need.


@aaghaei 

Yes indeed it removes all Where statement. Please add the original condition when calling (WereNew) if you want to keep it or manage your logic to prevent adding a condition (WhereAnd) when really is not needed, so you avoid removing it later in the call. 


@Leonardo Justiniano it is one of the Acumatica base views and this is developed this way. I can not really keey the Where Statement out of main query. But thank you for your time and help.


Reply