Skip to Content
Former Member
Aug 01, 2013 at 11:18 AM

How can I create a Business Partner programmatically?


I tried to create Business Partner programmatically using xml and created a series for Business Partner numbering that conforms to the CardCodes I want to assign (e.g. the first CardCode I use is precisely the one designated as next number in SBo and all other CardCodes are just increments of it) and tried to create new series and use these in the xml, but it still always returns me this error:

4002 To generate this document, first define the numbering series in the Administration module

Then I tried just using the BusinessPartners class and filling its porperties but it returns me this error: -5002 Code undefined [OCRD.CardCode]

This is the code:

BusinessPartners bp = DBProvider.myCompany.GetBusinessObject(BoObjectTypes.oBusinessPartners);            bp.CardName = "Create Test";                        bp.Addresses.TypeOfAddress = "B";            bp.Addresses.Street = "Ordensmeisterstr.";            bp.Addresses.StreetNo = "5";            bp.Addresses.ZipCode = "12099";            bp.Addresses.City = "Berlin";            bp.Addresses.Country = "DE";            bp.UserFields.Fields.Item("U_MANUMODGR").Value = "N";            bp.UserFields.Fields.Item("U_ISACCOUNT").Value = "N";            int returnvalue = bp.Add();            TB_Info.Text += "     retval: " + returnvalue.ToString();                        if (returnvalue != 0)            {                string msg;                DBProvider.myCompany.GetLastError(out returnvalue, out msg);                TB_Info.Text += "   " + msg;            }

How can I programmatically create many Business Partners? I need a lot of data for testing certain processes (10,000 or maybe even 100,000 Business Partners).

And what would be the fastest way?