Skip to main content

When I update the quantity of the top row. I’m updating all rows as well. I’m calling the RequestRefresh but its not refreshing. I know the quantities are being updated because when I refresh manually  they show. Interestingly, I’m doing the same in my Sales Order grid but its refreshing fine. What am I missing here ? How do I properly refresh the quote grid ?

 

 

Here’s the snippet of my code :

    private bool updatingqty = false;

    protected void CROpportunityProducts_Quantity_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
    {
      var row = (CROpportunityProducts)e.Row;
      if (row == null || updatingqty) return;
      updatingqty = true;
      foreach (CROpportunityProducts component in Base.Products.Select().RowCast<CROpportunityProducts>().Where(s => s.LineNbr != row.LineNbr))
      {
        cache.SetValueExt<CROpportunityProducts.quantity>(component, row.Quantity);
        Base.Products.Cache.Update(component);

      }
      updatingqty = false;
      Base.Products.View.RequestRefresh();
    }

 

TIA

The issue you're experiencing with the grid not refreshing in real-time after updating the quantities programmatically could be related to how the PXCache and PXView are being managed. While you’re setting the value and updating the cache for each row, the RequestRefresh() method may not be triggering the UI refresh properly in this context.

Here are a few things to check and suggestions to resolve this issue:

1. Ensure Proper Update Call:

  • When updating rows in a grid like CROpportunityProducts, it is essential that you use PXCache.Update() properly after setting the new value with SetValueExt().
  • Additionally, RequestRefresh() is generally not necessary after calling Cache.Update() because Acumatica should automatically refresh the grid.

Updated Approach:

Let's slightly adjust your code to ensure Acumatica's mechanisms work correctly:

 

csharp

 

private bool updatingqty = false; protected void CROpportunityProducts_Quantity_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e) { var row = (CROpportunityProducts)e.Row; if (row == null || updatingqty) return; updatingqty = true; // Get the current list of products var products = Base.Products.Select().RowCast<CROpportunityProducts>(); // Loop through and update each line except the current one foreach (CROpportunityProducts component in products.Where(s => s.LineNbr != row.LineNbr)) { // Ensure we're updating the field correctly cache.SetValueExt<CROpportunityProducts.quantity>(component, row.Quantity); cache.Update(component); // This updates the record in the cache } // Mark the current row as updated too cache.Update(row); updatingqty = false; }

Key Changes:

  1. No need for RequestRefresh():

    • Since you are updating the cache using cache.Update(component) for each modified row, Acumatica should automatically refresh the grid after exiting the event handler.
    • You only need to call cache.Update(row) for the current row to ensure its state is correctly updated.
  2. Trigger SetValueExt Correctly:

    • SetValueExt is used to trigger Acumatica’s field-level events and any related calculations. Ensure this is called before updating the cache.

2. Ensure Your DAC and Cache Settings are Correct:

  • Check that CROpportunityProducts is correctly set up in your graph and DAC for updates. If the caching behavior is misconfigured, it could result in the UI not refreshing correctly.

3. Manually Refresh the View if Necessary:

  • If for some reason the grid still does not refresh properly, try using Base.Actions.PressSave() instead of RequestRefresh() to force the page to rebind data and trigger a full refresh. However, this is generally not necessary unless the caching is complex.

4. Ensure Client-Side Interaction:

  • If this is a client-side interaction issue, ensure that no JavaScript overrides or front-end issues are preventing the grid from refreshing.

By following these suggestions, your grid should refresh correctly without the need for manual refreshes. If the issue persists, it could be related to more specific grid or UI behavior, in which case debugging the client-side response in Acumatica's UI might be necessary.

 

😀💡


Hi @Roderick,

Have you tried to set the SyncPosition = true,  under Layout properties for that grid?
this property refreshes the grid when grid value set to true.
Hope, it helps!


Hi @Roderick,

Have you tried to set the SyncPosition = true,  under Layout properties for that grid?
this property refreshes the grid when grid value set to true.
Hope, it helps!

its already true by default.


 

By following these suggestions, your grid should refresh correctly without the need for manual refreshes. If the issue persists, it could be related to more specific grid or UI behavior, in which case debugging the client-side response in Acumatica's UI might be necessary.

 

😀💡

thanks @chameera71 none of them works unfortunately. As I mentioned, same code in the Sales Order screen and is refreshing ok. 


@chameera71 - Any chance this is AI generated? 

@Roderick - Have you set CommitChanges=true for the Quantity column?


 Thinking through this more, this was a stupid question, given it’s use.

Have you set CommitChanges=true for the Quantity column?

This works for me:

protected virtual void _(Events.FieldUpdated<CROpportunityProducts, CROpportunityProducts.quantity> e)
{
CROpportunityProducts row = e.Row;
if (row is null) return;

var quoteGraph = e.Cache.Graph as QuoteMaint;

var linesToUpdate = quoteGraph.Products.Select()?.FirstTableItems?.Where(p => p.LineNbr != row.LineNbr);
foreach (CROpportunityProducts line in linesToUpdate)
{
quoteGraph.Products.Cache.SetValue<CROpportunityProducts.quantity>(line, row.Quantity);
}

quoteGraph.Products.View.RequestRefresh();
}

Note: no need to use updatingqty; use SetValue instead of SetValueExt to keep FieldUpdatping]ied] events from firing on those records


This works for me

 

 

hmm...not for me. are you able to share your project @darylbowman  ?


I tested this on 24 R1. What version are you on?


I tested this on 24 R1. What version are you on?

 

 

v2023R2

 

I’m getting this error trying to retrieve your attachment 

<Error>
<Code>MissingKey</Code>
<Message>Missing Key-Pair-Id query parameter or cookie value</Message>
</Error>

 


This also works for me in 23 R2. Is there another customization possibly interfering?

 

This code page is literally the only thing in the Customization Project. It’s not compiled:

using System;
using System.Linq;
using PX.Data;
using PX.Data.BQL;
using PX.Data.BQL.Fluent;
using PX.Objects;
using PX.Objects.CR;

namespace PX.Objects.CR
{
public class QuoteMaint_Extension : PXGraphExtension<PX.Objects.CR.QuoteMaint>
{
protected virtual void _(Events.FieldUpdated<CROpportunityProducts, CROpportunityProducts.quantity> e)
{
CROpportunityProducts row = e.Row;
if (row is null) return;

var quoteGraph = e.Cache.Graph as QuoteMaint;

var linesToUpdate = quoteGraph.Products.Select()?.FirstTableItems?.Where(p => p.LineNbr != row.LineNbr);
foreach (CROpportunityProducts line in linesToUpdate)
{
quoteGraph.Products.Cache.SetValue<CROpportunityProducts.quantity>(line, row.Quantity);
}

quoteGraph.Products.View.RequestRefresh();
}
}
}

 


thanks @darylbowman for your reply. there’s only one customisation and copied your code exactly. still not refreshing unfortunately so its really weird. 


I would suggest unpublishing everything, restarting the site, republishing only this one, and checking. I’m not sure I can help much beyond that.

As a last resort, you could repair the site by ‘upgrading’ it to the same version.


Reply