Skip to Content
0
Former Member
Jun 15, 2016 at 12:49 PM

How to insert the Address Component in a Invoice Draft

232 Views

Hi everyone!

I have a system that creates a Invoice Draft. I´m using the DI API and everything is alright except for the Address Component in the Logistics tab.

In the code I use this:

oDraft.AddressExtension.ShipToAddressType = recordSetCompany.Fields.Item("AddrType").Value.ToString();
oDraft.AddressExtension.ShipToStreet = recordSetCompany.Fields.Item("Street").Value.ToString();
oDraft.AddressExtension.ShipToStreetNo = recordSetCompany.Fields.Item("StreetNo").Value.ToString();
oDraft.AddressExtension.ShipToBuilding = recordSetCompany.Fields.Item("Building").Value.ToString();
oDraft.AddressExtension.ShipToZipCode = recordSetCompany.Fields.Item("ZipCode").Value.ToString();
oDraft.AddressExtension.ShipToBlock = recordSetCompany.Fields.Item("Block").Value.ToString();
oDraft.AddressExtension.ShipToCity = recordSetCompany.Fields.Item("City").Value.ToString();
oDraft.AddressExtension.ShipToState = recordSetCompany.Fields.Item("State").Value.ToString();
oDraft.AddressExtension.ShipToCounty = recordSetCompany.Fields.Item("County").Value.ToString();
oDraft.AddressExtension.ShipToCountry = recordSetCompany.Fields.Item("Country").Value.ToString();

This code works for the Ship To Address Component. But, for the Pay To Address Component, this code doesn´t work:

var oBP = (BusinessPartners)cp.GetBusinessObject(BoObjectTypes.oBusinessPartners);
oBP.GetByKey(recordSetBP.Fields.Item("CardCode").Value.ToString());

oDraft.AddressExtension.BillToAddressType = oBP.Addresses.TypeOfAddress;
oDraft.AddressExtension.BillToStreet = oBP.Addresses.Street;
oDraft.AddressExtension.BillToStreetNo = oBP.Addresses.StreetNo;
oDraft.AddressExtension.BillToBuilding = oBP.Addresses.BuildingFloorRoom;
oDraft.AddressExtension.BillToZipCode = oBP.Addresses.ZipCode;
oDraft.AddressExtension.BillToBlock = oBP.Addresses.Block;
oDraft.AddressExtension.BillToCity = oBP.Addresses.City;
oDraft.AddressExtension.BillToState = oBP.Addresses.State;
oDraft.AddressExtension.BillToCounty = oBP.Addresses.County;
oDraft.AddressExtension.BillToCountry = oBP.Addresses.Country;

This is correct? Any idea to do this works?

Best Regards.

Joao