Skip to main content
Answer

not valid in given context

  • September 18, 2023
  • 2 replies
  • 50 views

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.

2 replies

darylbowman
Captain II
Forum|alt.badge.img+15
  • 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
  • September 18, 2023

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