Results 1 to 4 of 4

Thread: Creating account with billing and shipping addresse via SOAP api?

  1. #1
    SugarRookie is offline Member
    Join Date
    Jul 2009
    Posts
    7

    Default Creating account with billing and shipping addresse via SOAP api?

    Hello,

    I'm using the Sugar SOAP api to create new accounts remotely via a code block something like this
    HTML Code:
    
    	require_once('lib/nusoap.php'); 
    
    	$client = new soapclient('http://myurl.com/soap.php?wsdl',true);  
    
    	$auth_array = array( 
    		'user_auth' => array (
    			  'user_name' => 'my-name',
    			  'password'  => md5('my-password'),
    			  'version' => '5.2.0',
    			)
    		); 
    
       $login_results = $client->call('login',$auth_array);
    	$session_id = $login_results['id'];
    	echo "Login Result: ".$session_id;
    
    	$create_user_data = array(
    	  'user_name' => 'my-name',
    	  'password'  => md5('my-password'),
    	  'name'  => 'Test name '.rand(),
    	  'phone'  => '555-555-4321',
    	  'website'  => 'www.testing.com',
    		);
    
    
    	echo "Creating account: \n";
    	echo $client->call('create_account', $create_user_data )."\n"; 
    This works fine, but I need to add in a shipping and a billing address for each new account.

    So is there a way I can do something like this?


    HTML Code:
    	$create_user_data = array(
    	  'user_name' => 'my-name',
    	  'password'  => md5('my-password'),
    	  'name'  => 'Test name '.rand(),
    	  'phone'  => '555-555-4321',
    	  'website'  => 'www.testing.com',
    	  'billing_address' => arrray( 
    			  'address_1' => '101 pine street',
    			  'address_2' => 'Apt 3',
    			  'city'      => 'My town',
    			  'state'     => 'My state',
    			  'zip'       => 'My Zip',
    			)
    	  'shipping_address' => arrray( 
    			  'address_1' => '101 elm street',
    			  'address_2' => 'Apt 3',
    			  'city'      => 'My town',
    			  'state'     => 'My state',
    			  'zip'       => 'My Zip',
    			)
    		);
    Thanks!!!
    Last edited by SugarRookie; 2009-07-27 at 07:10 PM.

  2. #2
    Angel's Avatar
    Angel is offline Sugar Community Member
    Join Date
    Jul 2005
    Location
    Los Angeles
    Posts
    4,813

    Default Re: Creating account with billing and shipping addresse via SOAP api?

    Use the set_entry() method instead of create_account().

    set_entry() will allow you to populate a defined list of fields beyond those possible with create_account.
    Regards,

    Angel Magaņa
    Co-Author: Implementing SugarCRM 5.x (Packt Publishing -- Sept. 2010)
    Blog: http://cheleguanaco.blogspot.com.
    Twitter: @cheleguanaco.

    ________
    | Projects: |_____________________________________
    |
    | CandyWrapper (.NET Wrapper for SugarCRM SOAP API). Source now available on GitHub!
    | GoldMine to SugarCRM Express Conversion. Latest: 1.0.1.7 (Nov. 3, 2009)
    | CRM SkyDialer (Skype Integration). Latest: 1.0.2 (Feb. 17, 2010)
    | Round Robin Leads Assignment
    | Phone Number Formatter
    | CaseTwit (Twitter Integration)
    ______________________________________________

  3. #3
    SugarRookie is offline Member
    Join Date
    Jul 2009
    Posts
    7

    Default Re: Creating account with billing and shipping addresse via SOAP api?

    Thanks for your response. I just have some questions about the specifics of your suggestion.

    1) How am I supposed to format the array to contain the address data? In my original post, I just guessed what the formatting should be. I.e.

    HTML Code:
    	$create_user_data = array(
    	  'user_name' => 'my-name',
    	  'password'  => md5('my-password'),
    	  'name'  => 'Test name '.rand(),
    	  'phone'  => '555-555-4321',
    	  'website'  => 'www.testing.com',
    	  'billing_address' => arrray( 
    			  'address_1' => '101 pine street',
    			  'address_2' => 'Apt 3',
    			  'city'      => 'My town',
    			  'state'     => 'My state',
    			  'zip'       => 'My Zip',
    
    The 'billing_address' block is just my best guess on the data exchange format. I browsed the soap.php?wsdl page and didnt see anything in the entire document about how to format the data for billing and or shipping address data.

    2) Just for clarification, if I correct the formatted data in the aforementioned array ( $create__user_array ), can I simply just modify the call from 'create_account' to 'set_entry' or do I have to make multiple calls? I.e. 'create_account' to create the account followed by 'set_entry'' to add the address data?

    Thanks for your help!

  4. #4
    Angel's Avatar
    Angel is offline Sugar Community Member
    Join Date
    Jul 2005
    Location
    Los Angeles
    Posts
    4,813

    Default Re: Creating account with billing and shipping addresse via SOAP api?

    I don't believe it will work if you pass the address as an array as I believe it always expects references to individual fields.

    Were you to change the $create_user_data array to reference single fields, like you did in the first part for phone, name, etc., that should work.

    Add 'id' => '' to the array as well. That will tell Sugar to create a new record (blank ID value). Also, you can omit the user/pass in that array as set_entry uses a session ID instead.

    After you've modified the array, you can then call set_entry by providing the following parameters:

    session_id, module_name, $name_value_list

    I do most of my API work through .NET, but I believe it would be something like this in PHP:

    $client->call('set_entry', $session_id, 'Accounts', $create_user_data)

    Lastly, regarding your point about multiple calls, set_entry is advantageous in that regard because it does not require more than one call to both create the record and populate the extra fields.
    Regards,

    Angel Magaņa
    Co-Author: Implementing SugarCRM 5.x (Packt Publishing -- Sept. 2010)
    Blog: http://cheleguanaco.blogspot.com.
    Twitter: @cheleguanaco.

    ________
    | Projects: |_____________________________________
    |
    | CandyWrapper (.NET Wrapper for SugarCRM SOAP API). Source now available on GitHub!
    | GoldMine to SugarCRM Express Conversion. Latest: 1.0.1.7 (Nov. 3, 2009)
    | CRM SkyDialer (Skype Integration). Latest: 1.0.2 (Feb. 17, 2010)
    | Round Robin Leads Assignment
    | Phone Number Formatter
    | CaseTwit (Twitter Integration)
    ______________________________________________

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 2009-06-23, 11:28 AM
  2. Billing & shipping address fields missing.
    By vishwasrao in forum Developer Help
    Replies: 2
    Last Post: 2009-04-21, 02:05 PM
  3. Lost Billing and Shipping Address fields
    By bstonehill in forum Help
    Replies: 4
    Last Post: 2008-09-08, 08:03 PM
  4. Replies: 2
    Last Post: 2008-08-23, 03:09 PM
  5. Replies: 0
    Last Post: 2005-03-26, 02:54 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •