Question

Is It Possible to Provide Filtering Conditions to Views?

  • 25 September 2023
  • 11 replies
  • 146 views

Userlevel 3
Badge
  • Jr Varsity III
  • 37 replies

Hi,

iam pulling SOLines items in a new grid using Soline view, but i Dont need all the SOLines and i need to apply a  filter, How can i modify my view to acheive that? any help is greatly Appriciated 

Thanks in Advance


11 replies

Userlevel 7
Badge +5

One option is to duplicate the view in your graph extension. Just copy the Transactions view definition from SOOrderEntry.cs and give the view a different name. Add in the extra criteria and then your new grid can pull it’s values from your new view.

Userlevel 3
Badge

Hi @Django ,

                     Thank you for the Response, iam aware of it, But in my case i have added a Dac Extension Bool Feild to the SOline, and when i select it only those records of SOLine need to pass to new grid. This is the existing view which i have. is there any possiblilty that i can add the Extension Dac Feild to the Conditon of this View?

        public PXSelect<
            SOLine, 
            Where<SOLine.orderType, Equal<Current<SOOrder.orderType>>,
                And<SOLine.orderNbr, Equal<Current<SOOrder.orderNbr>>>>> 
            SolineView; 

Badge +11

Yes, absolutely. You just need to include the DAC extension name instead of the original table name. For instance, possibly:

public SelectFrom<SOLine>.
Where<SOLine.orderType.IsEqual<SOOrder.orderType.FromCurrent>.
And<SOLine.orderNbr.IsEqual<SOOrder.orderNbr.FromCurrent>>.
And<SOLineExt.usrOtherField.IsEqual<something>>>.View SolineView;

 

Userlevel 3
Badge

Hi @darylbowman ,

                                Thank you for responding, I have Tried like this but the View Does not get Records

 

Badge +11

Could you post your code for the data view and also the custom DAC field?

I assume you’ve checked the database to verify the field you are querying actually has the value you expect?

Userlevel 3
Badge

        public PXSelect<
            SOLine,
            Where<SOLine.orderType, Equal<Current<SOOrder.orderType>>,
                And<SOLine.orderNbr, Equal<Current<SOOrder.orderNbr>>, And<SOLineExt.usrSelect, Equal<True>>>>>
            SolineView;

 

    #region UsrSelect
    [PXBool]
    [PXUIField(DisplayName="Select")]

    public virtual bool? UsrSelect { get; set; }
    public abstract class usrSelect : PX.Data.BQL.BqlBool.Field<usrSelect> { }

Userlevel 1

        public PXSelect<
            SOLine,
            Where<SOLine.orderType, Equal<Current<SOOrder.orderType>>,
                And<SOLine.orderNbr, Equal<Current<SOOrder.orderNbr>>, And<SOLineExt.usrSelect, Equal<True>>>>>
            SolineView;

 

    #region UsrSelect
    [PXBool]
    [PXUIField(DisplayName="Select")]

    public virtual bool? UsrSelect { get; set; }
    public abstract class usrSelect : PX.Data.BQL.BqlBool.Field<usrSelect> { }

Hi, I hope you’re doing well,

Maybe you can try to implement a view delegate, instead of a select statement.

If I understood the requirement correctly, You’re creating a new grid for selected SOLines, right?

If yes, then you can try and implement another view + delegate;
 

public SelectFrom<SOLine>.View SelectedTransactions;

public virtual IEnumerable selectedTransactions()
{
foreach(SOLine line in Base.Transactions.Select().RowCast<SOLine>().ToList().Where(x => x.GetExtension<Ext>()?.UsrSelect == true))
{
yield return line;
}
}

Something like this.

 

Or if it’s not the one that you want, Can you try doing this on your current view
 

public PXSelect<
            SOLine,
            Where<SOLine.orderType, Equal<Current<SOOrder.orderType>>,
                And<SOLine.orderNbr, Equal<Current<SOOrder.orderNbr>>, And<Current<SOLineExt.usrSelect>, Equal<True>>>>>
            SolineView;

Add Current on your SOLineExt.usrSelect

 

Hope this helps.

Badge +11

I’m noticing that the custom field you have is not a persisted field. This means that either through the UI or through code, you’d have to be setting UsrSelect to true. If this IS actually happening, chances are the view was cached before this happened, meaning that you’d probably need to be executing the select again in order for it to display the selected records.

To be clear, this is all speculation. Perhaps someone with more concrete knowledge like @Zoltan Febert or @Keith Richardson could confirm this.

Userlevel 7
Badge

Hi @Atiq were you able to find a solution? Thank you!

Userlevel 3
Badge

No @Chris Hackett ,

I have not Found the Solution for it Yet

Userlevel 3
Badge

Try using the view’s Cache.Updated to get the selected records

When the user selects the checkbox on the line it will add the record to the Updated list on the view’s cache.  You can just iterate that list for your process.

eg if you want to grab the selected lines from the SalesOrder Details into a list for processing...

List<SOLine> materials = Base.Transactions.Cache.Updated.RowCast<SOLine>().ToList();

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