+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 18 of 18

Thread: PHP -> Salesforce "upsert", can't get tutorial example working

  1. #11
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    557
    Blog Entries
    15
    The reason that you see Calls__c in your enterprise wsdl file is because it is generated from your org, for your org.

    The partner client has the ability to be able to use describeObject and describeGlobal that can get all custom tables / objects and fields on every object/table.

    ~Mike

  2. #12
    dxjones is offline Junior Member
    Join Date
    Jan 2010
    Posts
    8
    Ahhh! ... "describeObject" clears it up. Thanks!!

  3. #13
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    557
    Blog Entries
    15
    cool glad that sets you straight. try the script and let me know if you can get it to work!!

  4. #14
    dxjones is offline Junior Member
    Join Date
    Jan 2010
    Posts
    8
    Quote Originally Posted by mike View Post
    cool glad that sets you straight. try the script and let me know if you can get it to work!!
    Hey Mike,

    Here's an update.

    1. I got your code example to work. First time. Thanks a bunch!

    2. I sent Dave Carroll at Salesforce a quick note, and he confirmed the error in "upsert" in the Enterprise Client, so hopefully that will get fixed for everyone in the next update.

    3. The sObject class is defined within SforcePartnerClient.php instead of being in a file of its own. People wishing to use the Enterprise Client therefore need to include the Partner Client, just to get the definition of sObject. That seems counter-intuitive. It is also difficult to *find* the definition of sObject using grep, since it uses a capital "S" as in "class SObject".

    4. Back to the example code for "upsert". There is an issue with the result that gets returned. It *always* reports that the objects are successfully *created*, even when they are really being *updated*. Yes, the first time, it should be "created", but all subsequent "upserts" to the same objects should be "updated". I checked inside Salesforce and I am not mistakenly "creating" many copies of the same data. It is correctly identifying the objects using the unique external__id. On the Salesforce side of the transcation, it really is doing an "update".

    Can anyone confirm: Is this a *bug* in the Salesforce PHP Toolkit? Does it fail to distinguish between "create" and "update" ??

    thanks,
    David Jones

  5. #15
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    557
    Blog Entries
    15
    Quote Originally Posted by dxjones View Post
    Hey Mike,

    Here's an update.


    4. Back to the example code for "upsert". There is an issue with the result that gets returned. It *always* reports that the objects are successfully *created*, even when they are really being *updated*. Yes, the first time, it should be "created", but all subsequent "upserts" to the same objects should be "updated". I checked inside Salesforce and I am not mistakenly "creating" many copies of the same data. It is correctly identifying the objects using the unique external__id. On the Salesforce side of the transcation, it really is doing an "update".

    Can anyone confirm: Is this a *bug* in the Salesforce PHP Toolkit? Does it fail to distinguish between "create" and "update" ??

    thanks,
    David Jones

    Is this happening with the enterprise client? because I use the upsert all the time and I never see duplicates using the partner client

    Read this post again > PHP -> Salesforce "upsert", can't get tutorial example working

    tell me if you can see the difference between created and updated using upsert

    ~Mike

  6. #16
    dxjones is offline Junior Member
    Join Date
    Jan 2010
    Posts
    8
    To clarify, ... I am *not* seeing duplicates.

    I am using the Partner Client, and when I do an "upsert" for existing records, the update happens, but the result is *falsely* reported as being "created", when it should be "updated".

    If you run your demo code, the very first time (when the records are *new*) the result should be "created".
    If you run the demo code *again*, with the same records, the result should be "updated". ... but it is not. It is still "created". Even though the records were actually "updated" on Saleforce. (I checked.)

    Code:
    Array
    (
        [0] => stdClass Object
            (
                [created] => 
                [id] => a07300000053KvqAAE
                [success] => 1
            )
    
        [1] => stdClass Object
            (
                [created] => 
                [id] => a07300000053KvrAAE
                [success] => 1
            )
    
    )
    -- David

  7. #17
    dxjones is offline Junior Member
    Join Date
    Jan 2010
    Posts
    8
    ... or maybe I am just misunderstanding the API return value.

    Maybe "[created] => 1" means "created" and "[created] => NULL" means "updated".

    -- David

  8. #18
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    557
    Blog Entries
    15
    Quote Originally Posted by dxjones View Post
    ... or maybe I am just misunderstanding the API return value.

    Maybe "[created] => 1" means "created" and "[created] => NULL" means "updated".

    -- David
    That is exactly it!!! That is what I was trying to tell you earlier in the thread!!


    ~Mike

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2

Similar Threads

  1. Create Your own UPSERT script to Salesforce using PHP
    By mike in forum Salesforce PHP Tutorials
    Replies: 0
    Last Post: 11-30-2007, 08:15 AM

Tags for this 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