cancel
Showing results for 
Search instead for 
Did you mean: 

How can I create a Business Partner programmatically?

Former Member
0 Kudos

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?

Thanks.

Accepted Solutions (0)

Answers (1)

Answers (1)

edy_simon
Active Contributor
0 Kudos

Hi benjamin,

Can you test to create manually 1 bp from the sbo application using the user login?

It looks like an authorization problem.

Regards,

Edy

Former Member
0 Kudos

Hi,

Nope....

The only case (from what I know ) where you don't have to specify the CardCode while creating a BP is because you have created a document numbering schema for BP.

So, to make it working:

  • Administration / System Initialization / Document Numbering then either Customer or Vendor and you specify a CardCode format.
  • Then, you modify a bit the code and tell if it's a customer or a supplier... And B1 will generate the CardCode.

Besides the fact that it will certainly don't work for the sample, because of the address.

Regards,

Eric