您好我正在试图找到使用图表插入客户位置的正确方法。我目前正在使用PX.Objects.CR.CustomerLocationMaint图。但是当我插入或设置当前位置时,它总是为空。
这是我的代码
private PX.Objects.CR.Location UpdateCustomerLocation(PX.Objects.AR.Customer cust, ListingRead currentListing, ListingContactRelnListing contact)
{
PX.Objects.AR.CustomerLocationMaint g = new PX.Objects.AR.CustomerLocationMaint();
g.Clear(PXClearOption.ClearAll);
g.BusinessAccount.Current = cust;
PX.Objects.CR.Location loc = new PX.Objects.CR.Location();
loc.BAccountID = cust.BAccountID;
loc.LocationCD = "RL" + contact.contact.id;
loc.Descr = currentListing.property.system_search_key;
loc.DefContactID = cust.DefContactID;
loc.IsActive = true;
loc.LocType = "CU";
g.Location.Current = loc;
loc = g.Location.Insert(loc);
PX.Objects.CR.Address addr = new PX.Objects.CR.Address();
addr.BAccountID = cust.BAccountID;
addr.AddressType = "BS";
addr.CountryID = "NZ";
addr.AddressLine1 = currentListing.property.adr_street_number + " " + currentListing.property.adr_street_name;
addr.AddressLine2 = currentListing.property.adr_suburb_or_town;
addr.AddressLine3 = currentListing.property.adr_state_or_region;
addr = g.Address.Insert(addr);
loc.DefAddressID = addr.AddressID;
g.Location.Update(loc);
g.Actions.PressSave();
return loc;
}