We have a notification template set up which is fired by a business event when the status of a Shipment is set to confirmed. This works fine but we want the email to the customer to have their first name rather than account name. The Primary Contact first name is not exposed in the list of fields I can insert. I can see Primary Contact in the list but this seems to just be the numeric ID.
I tried adding a custom field to the shipments screen (SO302000) and set the visibility to false. This seemed to work and if I manually try to send an email with the source as the notification template the name appears. If I try with the business event the first name in the email is blank.
The field is defined as defined as a non-persisted text field and populated in the RowSelecting Event Handler:
public class SOShipmentEntry_Extension : PXGraphExtension<SOShipmentEntry>
{
#region Event Handlers
protected void SOShipment_RowSelecting(PXCache cache, PXRowSelectingEventArgs e, PXRowSelecting InvokeBaseHandler)
{
if(InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (SOShipment)e.Row;
if (row == null) return;
try {
// Get the first name from the primary contact record
SOShipmentExt soShipmentExt = row.GetExtension<SOShipmentExt>();
Contact shipContact = PXSelectJoin<Contact,InnerJoin<Customer, On<Contact.contactID, Equal<Customer.primaryContactID>>, InnerJoin<SOOrderShipment,On<Customer.bAccountID, Equal<SOOrderShipment.customerID>>>>, Where<SOOrderShipment.shipmentNbr, Equal<Required<SOOrderShipment.shipmentNbr>>>>.Select(Base, row.ShipmentNbr);
soShipmentExt.UsrPriContactFirstName = shipContact.FirstName;
} catch(Exception error) {
PXTrace.WriteInformation("Error is " + error);
}
}
}
Is there a different method I need to use to expose this information to the notification template or do I need to do something else so it can show up in the email fired by the business event?
Thanks for any advice/help,
Phil