Solved

not valid in given context

  • 18 September 2023
  • 2 replies
  • 36 views

Userlevel 1

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


                        }
                 }

        }

icon

Best answer by darylbowman 18 September 2023, 13:50

View original

2 replies

Badge +12

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.

Userlevel 7
Badge +18

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

 

 

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