+ Reply to Thread
Results 1 to 3 of 3

Thread: upsert question

  1. #1
    jeff is offline Junior Member
    Join Date
    Jul 2009
    Posts
    3

    upsert question

    Hi all,

    I want to insert contacts in salesforce if contacts do not exist and update the contacts details if they do exist.


    In my code I use $result = $client->upsert(array($sObject));
    instead of $result = $client->create(array($sObject));

    is it correct?

    how does sf know if the contact exist (and then perform an update)? Is it because I should pass the unique identifier for the client along with other info? If yes, what is the field's name I should use?


    $contacts = array();
    $contacts['FirstName'] = $fname';
    $contacts['LastName'] = $lname';
    $contacts['Phone'] = $pnumber';
    $contacts['Email'] = $'email';


    Many thanks

  2. #2
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    557
    Blog Entries
    15
    In order to use the upsert method you have to have a external key set on a field within the object in Salesforce. You can use the ID field to upsert, but we use a external field that is a text field

    and the correct line would be:

    PHP Code:
    $results $client->upsert("external_field__c"$sObjects); 
    OR
    PHP Code:
    $results $client->upsert("external_field__c", array($sObject)); 

    ~Mike

  3. #3
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    557
    Blog Entries
    15
    testsdfsadfasdf

+ Reply to Thread

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

SEO by vBSEO 3.5.1