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
sf_davesf_dave 

convertLead succeeds, upsert on resulting Account fails

All,

I can successfully call convertLead() on a lead I generate from the PHP API.  Upon successful conversion to an account, opportunity, and contact I update our local copies of the Salesforce ID so I can later upsert to the same account.

The problem is when I try to upsert on the converted account passing the ID returned by convertLead I get the following result returned from the API:

Code:
stdClass Object
(
    [created] => 1
    [errors] => stdClass Object
        (
            [fields] => Id
            [message] => cannot specify Id in an insert call
            [statusCode] => INVALID_FIELD_FOR_INSERT_UPDATE
        )

    [id] =>
    [success] =>
)

So I figured I should just remove the ID returned from the Salesforce API and pass my External ID to the upsert call and it will update the existing account, but it doesn’t.

It creates a second account that I can then upsert on infinity times using the ID returned from the upsert call.

Is there something wrong with the ID’s returned for accounts made through convertLead or are there any special steps I need to take to update the resulting account / opportunity / contact?

Thanks
-Dave

Park Walker (TAGL)Park Walker (TAGL)
Upsert uses an external Id field ( a custom field that you designate as an external id field ) to match the excisting records to the ones you send. In your Upsert call you need to specify the field to use for matching, not the salesforce.com assigned Id field. If you already have the Id of the newly created Accounts you can just use the Update call.

If you still want to use the Upsert call for some reason, you need to make sure that your external Id field from the Lead is getting mapped in the conversion process to a field that is defined as an external id field in the Account.

Hope this helps,
Park
sf_davesf_dave
I think that is the problem, thank you for jolting my memory...

I beleive this is the doc describing how to map custom fields:
https://na5.salesforce.com/help/doc/en/customize_mapleads.htm

Thanks,
-Dave


Message Edited by sf_dave on 02-05-2008 08:29 AM