Need assistance in passing data saved on a custom screen to a vendors screen cache to allow user to edit before saving. Current I m able to pass just the AcctCD data which gets passed through the url params
how do I pass the address details to the screen’s cache
public PXSelect<PHKyc> KycMain;
public PXSelect<PHKycBusiness, Where<PHKycBusiness.kycNbr, Equal<Current<PHKyc.kycNbr>>>> KycBusiness;
public PXAction<PHKyc> extendToVendor;
[PXUIField(DisplayName = "Extend to Vendor", MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Select)]
[PXButton]
public virtual IEnumerable ExtendToVendor(PXAdapter adapter)
{
PHKyc current = KycMain.Current;
PHKycBusiness business = KycBusiness.SelectSingle();
PX.Objects.CR.BAccount bAccount = new BAccount
{
AcctCD = current.KycNbr,
AcctName = business.BusinessName,
Type = BAccountType.VendorType,
AllowOverrideRate = false,
CuryRateTypeID = "SPOT",
AllowOverrideCury = false,
};
if (current != null && business != null)
{
base.Actions["Save"].Press();
VendorMaint vendorMaint = PXGraph.CreateInstance<VendorMaint>();
vendorMaint.TimeStamp = base.TimeStamp;
if (bAccount.Type != "CU" || bAccount.COrgBAccountID == 0)
{
bAccount.BaseCuryID = null;
}
VendorR vendorR = (VendorR)vendorMaint.BAccount.Cache.Extend(bAccount);
vendorMaint.BAccount.Cache.SetDefaultExt<PX.Objects.AP.Vendor.vOrgBAccountID>(vendorR);
vendorMaint.BAccount.Cache.SetDefaultExt<PX.Objects.AP.Vendor.curyID>(vendorR);
vendorMaint.BAccount.Cache.SetDefaultExt<PX.Objects.AP.Vendor.allowOverrideCury>(vendorR);
vendorMaint.BAccount.Cache.SetDefaultExt<PX.Objects.AP.Vendor.curyRateTypeID>(vendorR);
vendorMaint.BAccount.Cache.SetDefaultExt<PX.Objects.AP.Vendor.allowOverrideRate>(vendorR);
vendorMaint.CurrentVendor.Cache.SetDefaultExt<Vendor.acctName>(vendorR);
var address = new Address
{
AddressLine1 = business.AddressLine1 != null ? business.AddressLine1 : "",
AddressLine2 = business.AddressLine2 != null ? business.AddressLine2 : "",
CountryID = business.CountryId != null ? business.CountryId : "",
City = business.City != null ? business.City : "",
State = business.State != null ? business.State : "",
};
vendorMaint.BAccount.Current = vendorR;
vendorR.NoteID = current.Noteid;
vendorR.CreatedByID = bAccount.CreatedByID;
vendorR.Type = BAccountType.VendorType;
string aLocationType = BAccountType.VendorType;
VendorMaint.DefLocationExt extensionDefLocation = vendorMaint.GetExtension<VendorMaint.DefLocationExt>();
VendorMaint.DefContactAddressExt extensionDeAddress = vendorMaint.GetExtension<VendorMaint.DefContactAddressExt>();
// Set default values for Address fields
vendorMaint.GetExtension<VendorMaint.DefContactAddressExt>().DefAddress.Current = address;
VendorMaint.LocationDetailsExt extension2 = vendorMaint.GetExtension<VendorMaint.LocationDetailsExt>();
if (!base.IsContractBasedAPI)
{
throw new PXRedirectRequiredException(vendorMaint, "Edit Vendor", new { MyField = "Value" });
}
vendorMaint.Save.Press();
base.Actions.PressCancel();
}
return adapter.Get();
}