+ Reply to Thread
Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 23
This is a discussion on PHP -> Salesforce "upsert", can't get tutorial example working within the Salesforce PHP Tutorials forums, part of the Salesforce category; The reason that you see Calls__c in your enterprise wsdl file is
  1. #11
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16
    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
    607
    Blog Entries
    16
    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
    607
    Blog Entries
    16
    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 > http://www.mikesimonds.com/php-sales...9.html#post966

    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
    607
    Blog Entries
    16
    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

  9. #19
    sri
    sri is offline Junior Member
    Join Date
    Mar 2011
    Posts
    3

    PHP salesforce update Please help

    Hi
    I have spent enormous amount of time on this. am working for anon profit. I am using enterprise client as partner client gives me item invalid. i have tried everything here, but it simply doesnt work. I am trying to update fields in a contact table.

    $id = '003A000000XRVFxIAP';
    $data1 = 'Newyork';
    $updateFields = array ();
    $updateFields['FirstName'] = $data1;

    try{
    $sObject1 = new SObject();
    $sObject1->Id = $id;
    $sObject1->fields = $updateFields;
    $sObject1->type = 'Contact';
    $result = $client->update(array($sObject1),'Contact');
    if($result->success)
    {
    echo("<brsucexxssfo <br>");
    }
    else{

    }
    }

    I am getting the same error-- no such column 'fields' on entity contact, please help

    Strict Standards: Creating default object from empty value in C:\xampp\htdocs\Proj1\ForceToolkit\soapclient\Sfor ceEnterpriseClient.php on line 89
    INVALID_FIELD: No such column 'fields' on entity 'Contact'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.
    Error Info
    SoapFault exception: [sf:INVALID_FIELD] INVALID_FIELD: No such column 'fields' on entity 'Contact'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. in C:\xampp\htdocs\Proj1\ForceToolkit\soapclient\Sfor ceBaseClient.php:508 Stack trace: #0 C:\xampp\htdocs\Proj1\ForceToolkit\soapclient\Sfor ceBaseClient.php(508): SoapClient->__call('update', Array) #1 C:\xampp\htdocs\Proj1\ForceToolkit\soapclient\Sfor ceBaseClient.php(508): SoapClient->update(Object(stdClass)) #2 C:\xampp\htdocs\Proj1\ForceToolkit\soapclient\Sfor ceEnterpriseClient.php(90): SforceBaseClient->_update(Object(stdClass)) #3 C:\xampp\htdocs\Proj1\createAccount.php(93): SforceEnterpriseClient->update(Array, 'Contact') #4 {main

  10. #20
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    607
    Blog Entries
    16
    Well it is saying that you are missing a field called fields. I do not think that is a valid error. That error is being generated because you are using the enterprise client and i wrote this tutorial using the partner client. do not use the enterprise client because it is not as flexable as the partner client.

    Try the other client and get back to me, I think you will see that it will work

+ Reply to Thread
Page 2 of 3 FirstFirst 123 LastLast

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, 09: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.2