I am working to move a customer to Acumatica 2022 R2.
In their build, there was a delegate that we overrode (InsertDataIntoAppointmentDelegate)
The issue is we added some fields to the Service order that we want to carry over into the appointment automatically.
So, we called baseMethod.Invoke()
and then added our code after that:
{
baseMethod.Invoke(order, appt);
FSServiceOrderExt orderExt = order.GetExtension<FSServiceOrderExt>();
FSAppointmentExt aptExt = appt.GetExtension<FSAppointmentExt>();
//insert values
aptExt.UsrAuthorizedByContact = orderExt.UsrAuthorizedByContact;
aptExt.UsrFieldSiteContact = orderExt.UsrFieldSiteContact;
aptExt.UsrDoorLocation = orderExt.UsrDoorLocation;
aptExt.UsrLaborType = orderExt.UsrLaborType;
aptExt.UsrProductType = orderExt.UsrProductType;
aptExt.UsrCustomerIsExempt = orderExt.UsrCustomerIsExempt;
aptExt.UsrTaxExempt = orderExt.UsrTaxExempt;
}
It seems in this release, I need to change the PXAction of the Button. But I don’t see how I can do anything like the baseMethod.Invoke()
I find it in the source code, but I am unclear as to how I can just add my code to the action
Any guidance on how to do that?
This is the Source of the existing action:
public PXAction<FSServiceOrder> scheduleAppointment;
PXUIField(DisplayName = "Create Appointment", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
PXButton(OnClosingPopup = PXSpecialButtonType.Cancel)]
public virtual IEnumerable ScheduleAppointment(PXAdapter adapter)
{
List<FSServiceOrder> list = adapter.Get<FSServiceOrder>().ToList();
foreach (FSServiceOrder fsServiceOrderRow in list)
{
ValidateContact(fsServiceOrderRow);
SkipTaxCalcAndSaveBeforeRunAction(ServiceOrderRecords.Cache, fsServiceOrderRow);
if (SharedFunctions.isThisAProspect(this, fsServiceOrderRow.CustomerID))
{
throw new PXException("Error");
}
var graphAppointmentEntry = PXGraph.CreateInstance<AppointmentEntry>();
FSAppointment fsAppointmentRow = new FSAppointment()
{
SrvOrdType = ServiceOrderRecords.Current.SrvOrdType,
SOID = ServiceOrderRecords.Current.SOID
};
fsAppointmentRow = graphAppointmentEntry.AppointmentRecords.Insert(fsAppointmentRow);
graphAppointmentEntry.AppointmentRecords.SetValueExt<FSAppointment.soRefNbr>(graphAppointmentEntry.AppointmentRecords.Current, fsServiceOrderRow.RefNbr);
graphAppointmentEntry.AppointmentRecords.SetValueExt<FSAppointment.customerID>(graphAppointmentEntry.AppointmentRecords.Current, fsServiceOrderRow.CustomerID);
throw new PXRedirectRequiredException(graphAppointmentEntry, null);
}
return list;
}