Solved

Problem "refresh" (recalculating field) of grid

  • 19 October 2021
  • 5 replies
  • 681 views

Userlevel 2

Hi, Good night.

 

I want to recalculate the field (% Above Winner) when a new row is inserted/updated/deleted. I did the method (and it works) but when i put this method in a event of the same grid i got an error/debuggin visual studio warning. But if i put the method in other field (other tab etc, no in the same grid) it works.

Can you helpme please? i paste some images to explain me better.

 

 

1.- this is the grid. I need to recalculate the column “%  AboveWinner “(for all rows) for Add,Update, Delete action.
2.- when i put the method “getAboveWinners” in the update field event of this grid i got an “error”
This is the error.
When i put the method in other button/tab etc (not in the same grid) it works!
    public void getAboveWinners()
{
int countLowestValue=0;
decimal? lowestValue=0;
//we get the lowest value;
foreach (CEEstimateBidWinner soLine in this.viewCEEstimateBidWinner.Select())
{
if(lowestValue==0)
{
lowestValue=soLine.TotalBid;
}
else if(lowestValue>=soLine.TotalBid)
{
lowestValue=soLine.TotalBid;
}
}

foreach (CEEstimateBidWinner soLine in this.viewCEEstimateBidWinner.Select())
{
decimal? resultado=((soLine.TotalBid/lowestValue)-1)*100;
soLine.PercentageAboveWinner=resultado;
viewCEEstimateBidWinner.Update(soLine);
}
}

 

Can you help me please, thanks!

icon

Best answer by Naveen Boga 19 October 2021, 08:17

View original

5 replies

Userlevel 7
Badge +17

Hi @eddiedaco  Since the problem is related to refreshing the grid. You can add the below at last of your code and verify.

Graph.ViewName.View.RequestRefresh();

 

Hope this helps!!

Userlevel 2

Hi @Naveen B  

Graph.ViewName.View.RequestRefresh(); “works” (visually) but when i save the information. Its saves the “old” information not the new.

Userlevel 7
Badge +17

Which means cache values are NOT persisting to Save the values in database.

Did you debug and check did cache holds the updated values?

Userlevel 5
Badge +2

@eddiedaco When putting the getAboveWinners method in the fieldUpdated event, make sure the other rows have status Updated, otherwise the cache will ignore them and will not be saved:

foreach (CEEstimateBidWinner soLine in this.viewCEEstimateBidWinner.Select())
{
decimal? resultado=((soLine.TotalBid/lowestValue)-1)*100;
soLine.PercentageAboveWinner=resultado;
viewCEEstimateBidWinner.Update(soLine);
if(this.viewCEEstimateBidWinner.Cache.GetStatus(soLine) != PXEntryStatus.Inserted)
this.viewCEEstimateBidWinner.Cache.SetStatus(soLine, PXEntryStatus.Updated);
}

 

Userlevel 2

The problem was the “update” of yourview.Update. for every iteration the “.update” show error. The solution was change .update for yourview.Cache.SetValue<yourDAC.yourField>
                (soLine, yourvalue)

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