cancel
Showing results for 
Search instead for 
Did you mean: 

insert BP adress

Former Member
0 Kudos

i'm trying to insert ship to address an bill to address to a BusinessPartner using JAVA.

code:

IBusinessPartners ib = SBOCOMUtil.newBusinessPartners(company);

ib.setCardCode("994");

ib.setCardName(bp.getNome());

ib.setCardType(SBOCOMConstants.BoCardTypes_cCustomer);

ib.setEmailAddress(bp.getEMail());

ib.setPhone1(bp.getTelefone());

ib.setCellular(bp.getTelCel());

ib.setFax(bp.getFax());

ib.getUserFields().getFields().item("U_nomeMae").setValue(bp.getNomeMae());

ib.add();

System.out.println(company.getLastErrorDescription());

ib.getAddresses().setAddressName("Cobrança");

ib.getAddresses().setCurrentLine(0);

ib.getAddresses().setStreet(bp.getEndereco());

ib.getAddresses().setCity(bp.getCidade());

ib.getAddresses().setZipCode(bp.getCep());

ib.getAddresses().setAddressType(SBOCOMConstants.BoAddressType_bo_BillTo);

ib.getAddresses().setState("SP");

ib.getAddresses().setCountry("BR");

ib.getAddresses().setBlock("");

ib.getAddresses().add();

ib.getAddresses().setAddressName("Entrega");

ib.getAddresses().setCurrentLine(1);

ib.getAddresses().setStreet(bp.getEndereco());

ib.getAddresses().setCity(bp.getCidade());

ib.getAddresses().setZipCode(bp.getCep());

ib.getAddresses().setState("SP");

ib.getAddresses().setCountry("BR");

ib.getAddresses().setBlock("");

ib.getAddresses().setAddressType(SBOCOMConstants.BoAddressType_bo_ShipTo);

ib.getAddresses().add();

ib.setShipToDefault("Cobrança");

ib.update();

when I execute this code, It inserts the BP but it does not insert the adresses.

I get this message: <b>"The object's key is not set"</b>

What am i doing wrong?

Please, if anyone could help me, i'll apreciate it.

Even C# examples

tks

Elcio

Accepted Solutions (1)

Accepted Solutions (1)

Gianluigi
Product and Topic Expert
Product and Topic Expert
0 Kudos

Trying adding a GetByKey after the add ...

Answers (1)

Answers (1)

olivier_huet3
Participant
0 Kudos

Try this :

Remove "ib.update();"

Move the "ib.add();" and the end (in place of "ib.update();")

Delete the last "ib.getAddresses().add();"

(you have to call "ib.getAddresses().add();" before adding address and not after, but it is not needed for the first address)