Skip to main content
Solved

not valid in given context


Forum|alt.badge.img

I need to set SONbr to only transfer Screen(IN304000) warehouse equal to sales Order screen(SO301000) warehouse(siteID).

 

errors in :     if (sOLine.siteID == row.siteID)

 

 

this is my code: 

protected void INTran_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            //Row selected for UsrSONbr
            var row = (INTran)e.Row;

            if (row == null) return;

                SOLine sOLine = new PXSelect<SOLine, Where<SOLineExt.usrTransferNbr,
                                                Equal<Required<SOLineExt.usrTransferNbr>>,
                                                And<SOLine.inventoryID, Equal<Required<SOLine.inventoryID>>>>>
                                                (Base).Select(row.RefNbr, row.InventoryID);
            if (sOLine != null)

                //if (typeof(SOLine.siteID) == typeof(INSite.siteID))
                if (sOLine.siteID == row.siteID)
                {

                        {

                            INTranExt iNTranExt = PXCache<INTran>.GetExtension<INTranExt>(row);
                            iNTranExt.UsrSONbr = sOLine.OrderNbr;
                            cache.SetValueExt<INTranExt.usrSONbr>(row, iNTranExt.UsrSONbr);


                        }
                 }

        }

Best answer by darylbowman

In regular code (not BQL statements or typeof() statements, the field names must be capitalized.

if (sOLine.siteID == row.siteID)

should be 

if (sOLine.SiteID == row.SiteID)

Additionally, you're running several database queries in RowSelected which is not advised.

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

2 replies

darylbowman
Captain II
Forum|alt.badge.img+13
  • 1606 replies
  • Answer
  • September 18, 2023

In regular code (not BQL statements or typeof() statements, the field names must be capitalized.

if (sOLine.siteID == row.siteID)

should be 

if (sOLine.SiteID == row.SiteID)

Additionally, you're running several database queries in RowSelected which is not advised.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • September 18, 2023

@tharinduweerasooriya90  Please refer to the below example, which solves this problem as well

 

 


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