function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
gaxgax 

Adding a customer to Account via Java WSDL

Hi Guys,
I'm brand new to the salesforce web services APIs and am trying to feel my way around in Java.

What I'd like to do, is create a contact, create and account for that contact, add the contact to the account, then create and Opporunity and add the account to the Opportunity.

I'm stuck on the Account object's setContacts(QueryResult) method.
So I have to issue a query that returns the correct set of contacts that I want to be in this account then set this QueryResult into the account via setContacts()? 
Is there no way to just add a new contact to an accont from the WSDL side?

sorry if I'm missing something obvious.

Thanks!
-John

ganeshjganeshj

Hi,

  We can create contacts/opportunity through apex webservices API. Then call the  "create"   method in

com.sforce.soap.enterprise.SoapBindingStub.java, it will take array of SObjects as input. The SObjects can be contact/account/opportunity of

salesforce.com. Be sure that you have set all the properties which is mandatory for the object.

 

Thanks,

Ganesh

SuperfellSuperfell
No, the contacts property is purely there for querying.

To associate the contact with the account, you would set the accountId property of the contact to be the Id value of the account.