I want to change the behaviour of the defaulting of dimension values on the Vendor invoice header when each Purchase order is added to a Vendor invoice.
The customisation has to read all existing dimension values on all PO lines added and based on those values will write certain dimension values on the Invoice header.
Currently in the VendEditInvoice form, the method setHeaderFields() dynamically takes values from the PurchTable and populates the form:
if (isNonPO)
{
dimensionDefaultingControllerHeader.parmAttributeValueSetDataSource(vendInvoiceInfoTable_ds, fieldStr(VendInvoiceInfoTable, DefaultDimension));
// dimensionDefaultingControllerHeader.setEditability(true);
dimensionDefaultingControllerHeader.updateValues(NoYesUnchanged::Yes);
}
else
{
dimensionDefaultingControllerHeader.parmAttributeValueSetDataSource(purchTable_ds, fieldStr(PurchTable, DefaultDimension));
// dimensionDefaultingControllerHeader.setEditability(false);
dimensionDefaultingControllerHeader.updateValues(NoYesUnchanged::No);
}
My main question is: What is the best way to customise the existing behaviour in this scenario without compromising existing functionality if possible?
One of my concerns is the method DimensionDefaultingController.parmAttributeValueSetDataSource().
This looks as though it sets up event handlers to respond to any change of financial dimension values on the PO by auto-updating the Vendor Invoice financial dimension values?
I'm unsure how this actually works but presume it only operates for while the form is loaded and before the invoice is saved?
thanks