Get Selected checkbox in grid to post back on Process Shipments screen when selected/unselected

  • 29 March 2024
  • 5 replies

Userlevel 6
Badge +3

I have a custom field in the header of the Process Shipments screen header called Total Selected Price.  There is also a custom field in the grid called Extended Price.

When a user selects a record in the grid, I want to update the total in the header.


I added CommitChanges = True to the Selected checkbox in the grid.

In my code, I added the following event handler to update the total when a checkbox is changed

protected void _(Events.FieldUpdated<SOShipment, SOShipment.selected> e)
SOShipmentFilter filter = Base.Filter.Current;

var row = (SOShipment)e.Row;

GTISOShipmentExt extLine = PXCache<SOShipment>.GetExtension<GTISOShipmentExt>(row);
if (extLine == null) return;

SOShipmentFilterExt extHeader = PXCache<SOShipmentFilter>.GetExtension<SOShipmentFilterExt>(filter);
if (extHeader == null) return;

if (row.Selected == true)
extHeader.UsrTotalSelectedPrice += extLine.UsrExtendedPrice;
extHeader.UsrTotalSelectedPrice -= extLine.UsrExtendedPrice;

Problem 1:

When the checkbox is changed, it is not firing this code.  If I check the box and click the refresh on the screen (not refresh the entire page, the refresh button in the toolbar), this code is fired.  But that logic will not increment/decrement the total as the checkboxes are selected/unselected.

Problem 2:

Then after it fires on a screen refresh, I can see that the total is being updated on the custom header field, but it is not actually updating the field on the screen.  Perhaps even though I am setting a value in the custom header (filter section) field, it is being reset back to zero?

I tried using a PXFormula in the DAC extension to sum the values in the grid where the checkbox is selected, but you cannot put a condition in the PXFormula.  I don’t know if that would do anything anyway since the cache only seems to update on a refresh of the screen.

I have a workaround using the RowSelected handler on the filter.  Then I put a “dummy” action button on the screen to REFRESH SELECTED TOTALS which refreshes the screen to show the total.

I think if I could get the FieldUpdated to fire when the checkbox is updated, it would be a much cleaner solution.

FYI, I also tried setting the cache on the grid to allow updates.  That didn’t make any difference in allowing the checkbox to fire.

Any ideas?


Best answer by Joe Schmucker 1 April 2024, 17:18

View original

5 replies

Userlevel 7
Badge +4

@Joe Schmucker Have you tried view refresh in your event handler:

Problem "refresh" (recalculating field) of grid | Community (

Userlevel 6
Badge +3

Hi @RohitRattan88 The problem is that the evet handler is not being fired when you click the checkbox.

The event handler fires only when you click the refresh icon in the toolbar.  It is like the grid handlers only get fired when the page is refreshed or after you click a process button.

Thanks for the idea though!

Userlevel 7
Badge +4

@Joe Schmucker If I am not mistaken, Selected field is an Unbound and I am not sure if fieldUpdated could be used.

For unbound data fields that are displayed only in the UI, you can use only the FieldSelecting event that defines the UI presentation of the value.

Ref: External and Internal Presentation of Field Values: General Information

Userlevel 6
Badge +3

@RohitRattan88 I will give that a try and let you know how it goes!

Userlevel 6
Badge +3

I’ve confirmed that there is no postback from the grid on the processing screen.  My workaround is to put a REFRESH button on the header and when the user clicks it, it loops through the grid and calculates the total for selected rows.



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