0

I can create a person account using the REST API, but I can't seem to find any documentation on how to create a business account. I imaging that the post items you send need to include something extra that identifies this new account as a business account, but WHAT is it?

I am using PHP cURL to accomplish this.

    $content = json_encode( array(
        "LASTNAME"                  => $dealer->last_name,
        "FIRSTNAME"                 => $dealer->first_name,
        "PERSONMAILINGSTREET"       => $dealer->address . ' ' . $dealer->address2,
        "PERSONMAILINGCITY"         => $dealer->city,
        "PERSONMAILINGSTATE"        => $dealer->state,
        "PERSONMAILINGPOSTALCODE"   => $dealer->zip,
        "PERSONMAILINGCOUNTRY"      => 'US',
        "PERSONEMAIL"               => $dealer->email,
        "SPEQ_Dealer__c"            => 'Yes',
    ) );

    $curl = curl_init( $url );
    curl_setopt( $curl, CURLOPT_HEADER, false );
    curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $curl, CURLOPT_HTTPHEADER,
            array("Authorization: OAuth $access_token",
                "Content-type: application/json" ) );
    curl_setopt( $curl, CURLOPT_POST, true );
    curl_setopt( $curl, CURLOPT_POSTFIELDS, $content );

This code works, but what am I missing? I can't find a list of database table fields to work with either, so any help on that front would be great too!

2 Answers 2

1

You're going to use the same endpoint. PersonAccounts are a weird Mashup of an entry in the Account table and an Entry in the Contact table. Linked by a foreign key Account.ContactId

That said you'll not want to send First/Last Name or PersonAddress, etc

Use: Name, and then ShippingStreet (etc), and/or BillingStreet (etc)

You will likely have to specify a value for RecordTypeId as well. You can find this under the setup menu>accounts>recordtypes (in the URL)

Here are your fields:

9
  • Thank you for the fields. I have been searching for a while. I will give this a shot and let you know! Commented Aug 9, 2017 at 18:49
  • failed with status 400, response [{"message":"Unable to create/update fields: Name. Please check the security settings of this field and verify that it is read/write for your profile or permission set.","errorCode":"INVALID_FIELD_FOR_INSERT_UPDATE","fields":["Name"]}], curl_error , curl_errno 0 Commented Aug 9, 2017 at 18:55
  • No go on that "Name" I guess I need more permissions for this to work properly? Commented Aug 9, 2017 at 18:56
  • Possible under Setup>manage users>profiles you should find the user you're using and check the field level security of the name field. Another possibility is that you're still trying to create a PersonAccount and you can't write to the Name (must use first/last) are you sending a recordtypeid? that is what controls business vs person
    – wellmstein
    Commented Aug 9, 2017 at 19:08
  • yes I am sending the RecordTypeId and it is in line with all the other business accounts. I will double check to see if there is a permissions issue in the dashboard for my user. Commented Aug 9, 2017 at 19:10
1

Ok so this is what ended up being the issue:

1. I wasn't using the correct RecordTypeId.

2. I needed to create a Contact that could reference the Business Account we had created.

3. After creating the Customer Account, I had to create AccountContactRole information linking the two together.

4. Once that connection was made I could update the Business Account and post the customer's ContactId field into their custom configuered field Point of Contact.

I dont think this is normal, but what @wellmstein said worked perfectly. Thanks for the help.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .