Good day
Build 20.107.0026
Screen id FS300200
I have created a button on the Appointments screen that does some work and to calculate the long and Latitude of an address.
I have extended my Adress and added the usrDeliveryAddressLongitude & usrDeliveryAddressLattitude.
but for the life of me, I can't get this thing to save to the DB.
I have another button on the same screen and when I debug, the button references the above fields and can see that the data is there.
What is the correct way to save the AddressExt data in a button on the Appointments screen?
public PXSelect<
Address,
Where<Address.bAccountID, Equal<Current<BAccount.bAccountID>>>> Addresslist;
public PXAction<PX.Objects.FS.FSAppointment> DoWork;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "DoWork")]
protected void doWork()
{
try
{
FSServiceOrder curFSServiceOrder = Base.ServiceOrderRelated.Current;
//check customerID
BAccount curBAccount = PXSelect<
BAccount,
Where<BAccount.bAccountID, Equal<Required<FSServiceOrder.customerID>>>>
.Select(Base, curFSServiceOrder.CustomerID);
string DeliveryAddressLongitude = "";
string DeliveryAddressLattitude = "";
//DeliveryAddress
Location curLocation = PXSelect<
Location,
Where<Location.bAccountID, Equal<Required<BAccount.bAccountID>>,
And<Location.locationID, Equal<Required<FSServiceOrder.locationID>>>>>
.Select(Base, curBAccount.BAccountID, curFSServiceOrder.LocationID);
Address curAddress = PXSelect<
Address,
Where<Address.addressID, Equal<Required<Location.defAddressID>>,
And<Address.bAccountID, Equal<Required<BAccount.bAccountID>>>>>
.Select(Base, curLocation.DefAddressID, curBAccount.BAccountID);
//Removed code that is not needed
DeliveryAddressLongitude = "fakeLong";
DeliveryAddressLattitude = "fakeLant";
// the below is a couple of things I have tried, i removed a couple of them that where
// not working at all
Addresslist.SetValueExt<AddressExt.usrDeliveryAddressLongitude>(curAddress, DeliveryAddressLongitude);
Addresslist.SetValueExt<AddressExt.usrDeliveryAddressLattitude>(curAddress, DeliveryAddressLattitude);
AddressExt curAddressExt = PXCache<Address>.GetExtension<AddressExt>(curAddress);
curAddressExt.UsrDeliveryAddressLattitude = DeliveryAddressLattitude;
curAddressExt.UsrDeliveryAddressLongitude = DeliveryAddressLongitude;
Addresslist.Update(curAddress);
Base.Caches<Address>().Cached.
//FSAppointment curFSAppointment = Base.AppointmentRecords.Current;
//FSAppointmentExt curFSAppointmentExt = curFSAppointment.GetExtension<FSAppointmentExt>();
// Base.
//Addresslist.Update(curAddress);
}
catch (Exception ex)
{
PXTrace.WriteError(ex);
}
}