Solved

Multiple iterators and the cache

  • 24 August 2022
  • 1 reply
  • 58 views

Userlevel 7
Badge +5

I have a customization that will travel through the lines of a sales order. 

There could be two groups of SOLine records that I need to process on the same SO.

I have one main var to look at the SOLine records:

var lines = SelectFrom<SOLine>.
Where<SOLine.orderType.IsEqual<SOOrder.orderType.FromCurrent>
.And<SOLine.orderNbr.IsEqual<SOOrder.orderNbr.FromCurrent>>>.
View.Select(soOrderEntry);

Then I’m using:

foreach(SOLine line in lines)
{
//A bunch of code here
}

If I need another iterator to go through SOLine records on the same SO within the foreach loop and write (can I have multiple iterators on the same PXSelect?):

foreach(SOLine lineTwo in lines)
{
//A bunch of code here
}

If I update lineTwo with:

soOrderEntry.Transactions.Update(lineTwo);

Will that update the proper record or will having multiple variables confuse the cache?

icon

Best answer by Naveen Boga 24 August 2022, 07:23

View original

1 reply

Userlevel 7
Badge +17

Hi @ddunn  I don’t think two foreach loops are required.

You can use the single foreach loop with your logic like below and update the cache.

 

foreach(SOLine line in lines)

{

      // execute the first logic and assign the respective values to the line object

       Eg: line.CuryUnitPrice =100;

             line.Qty = 2; 

 

   //execute the second logic and assign the values to the line object

   Eg: line. CuryDiscAmt =10

//Finally you update the cache, which will update both logic values.

SOGraph.Transactions.cache.update(line);

}

 

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