Skip to main content
Solved

Multiple iterators and the cache

  • 24 August 2022
  • 1 reply
  • 72 views

Forum|alt.badge.img+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?

Best answer by Naveen Boga

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

}

 

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

1 reply

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3377 replies
  • Answer
  • August 24, 2022

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


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