Skip to main content
Solved

Is It Possible to Provide Filtering Conditions to Views?


Atiq
Jr Varsity III
Forum|alt.badge.img
  • Jr Varsity III
  • 38 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

Best answer by gprice27

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();

View original
Did this topic help you find an answer to your question?

11 replies

Forum|alt.badge.img+5
  • Captain II
  • 468 replies
  • September 25, 2023

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.


Atiq
Jr Varsity III
Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 38 replies
  • September 26, 2023

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; 


darylbowman
Captain II
Forum|alt.badge.img+13

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;

 


Atiq
Jr Varsity III
Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 38 replies
  • September 26, 2023

Hi @darylbowman ,

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

 


darylbowman
Captain II
Forum|alt.badge.img+13

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?


Atiq
Jr Varsity III
Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 38 replies
  • September 26, 2023

        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> { }


lgalleno31
Freshman I
  • Freshman I
  • 4 replies
  • September 26, 2023
Atiq wrote:

        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.


darylbowman
Captain II
Forum|alt.badge.img+13

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.


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2546 replies
  • November 2, 2023

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


Atiq
Jr Varsity III
Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 38 replies
  • November 3, 2023

No @Chris Hackett ,

I have not Found the Solution for it Yet


gprice27
Jr Varsity I
Forum|alt.badge.img
  • Jr Varsity I
  • 25 replies
  • Answer
  • April 11, 2024

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings