Skip to main content
Answer

How do I add custom code to the FieldUpdated event for the Ship To address and billing address on an Sales Order?

  • May 19, 2025
  • 2 replies
  • 54 views

Forum|alt.badge.img+1

I have successfully set up a field on the Customers Default Address to flag if the address is verified.  On the Customers screen adding a FieldUpdated event for AddressLine1 allowed me to reset this flag if the field was edited.

This is the code:

protected void Address_AddressLine1_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
  InvokeBaseHandler(cache, e);
  var row = (Address)e.Row;
      
  if (row == null) return;

  var addrExt = PXCache<Address>.GetExtension<AddressExt>(row);

 if (addrExt?.UsrAIAddressVerified == true)
  {
  cache.SetValueExt<AddressExt.usrAIAddressVerified>(row, false);
  }
}

This works great on the Customers screen. If I edit Address Line 1 and tab away it resets the flag. I want to reproduce the same thing on the Shipping Address on the Sales Order Screen.

I added the following:

protected void SOShippingAddress_AddressLine1_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (SOShippingAddress)e.Row;

if (row?.AddressID == null)
return;

// Fetch SOAddress record by AddressID
var soAddress = PXSelect<SOAddress,
Where<SOAddress.addressID, Equal<Required<SOShippingAddress.addressID>>>>
.Select(Base, row.AddressID).TopFirst;

if (soAddress != null)
{
var soAddrCache = Base.Caches<SOAddress>();
var addrExt = PXCache<SOAddress>.GetExtension<SOAddressExt>(soAddress);

if (addrExt?.UsrAIShipAddressVerified == true)
{
soAddrCache.SetValueExt<SOAddressExt.usrAIShipAddressVerified>(soAddress, false);
soAddrCache.Update(soAddress); // make sure change is tracked
}
}
}

When I debug this and add a breakpoint inside the function it never triggers when I type into the Address Line 1 field of the Shipping Address.  Am I missing something obvious? It does trigger if I click the override address button but doesn’t reset the flag.

 

Any help would be gratefully received,

Phil

Best answer by aleksejslusar19

The “AddressLine1” field does not contain the CommitChanges attribute.

<px:PXTextEdit ID="edAddressLine1" runat="server" DataField="AddressLine1" ></px:PXTextEdit> 


Try adding CommitChanges=“True” to the field definition and it will most likely solve the problem.

2 replies

darylbowman
Captain II
Forum|alt.badge.img+15

Does the ‘Address Line 1’ field commit changes?


Forum|alt.badge.img+1

The “AddressLine1” field does not contain the CommitChanges attribute.

<px:PXTextEdit ID="edAddressLine1" runat="server" DataField="AddressLine1" ></px:PXTextEdit> 


Try adding CommitChanges=“True” to the field definition and it will most likely solve the problem.