+ Reply to Thread
Results 1 to 6 of 6

Thread: update, queryMore problems

  1. #1
    murraybiscuit is offline Junior Member
    Join Date
    Nov 2007
    Posts
    5

    Angry update, queryMore problems

    Look, as far as I'm concerned, Salesforce shouldn't offer the PHP toolkit if they don't have an API with PHP code. It's wasted a lot of my time...

    - Using a developer account
    - disbled wsdl caching
    - using the partner wsdl
    1. queryMore - i have followed all examples, tried different angles:
      • after the initial query(), "done" returns true and "queryLocator" has no value.
      • i can set "done" to false in order to start a loop for queryMore, but queryLocator still has no value and so the function returns an error.
    2. update - i construct an SObject and send it off, get success=1, but the record in salesforce stays the same. I suspect it may have something to do with the way I have constructed the fields in the SObject, but I can't see anything inconsistent with other examples or with what the soapclient functions require.
    Please help

  2. #2
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    557
    Blog Entries
    15
    Quote Originally Posted by murraybiscuit View Post
    Look, as far as I'm concerned, Salesforce shouldn't offer the PHP toolkit if they don't have an API with PHP code. It's wasted a lot of my time...

    - Using a developer account
    - disbled wsdl caching
    - using the partner wsdl
    1. queryMore - i have followed all examples, tried different angles:
      • after the initial query(), "done" returns true and "queryLocator" has no value.
      • i can set "done" to false in order to start a loop for queryMore, but queryLocator still has no value and so the function returns an error.
    2. update - i construct an SObject and send it off, get success=1, but the record in salesforce stays the same. I suspect it may have something to do with the way I have constructed the fields in the SObject, but I can't see anything inconsistent with other examples or with what the soapclient functions require.
    Please help

    Post some of your code and I will try and help you out. While I agree with your statement, there are some examples on the developer network and here that work right out of the box, but again let me check out your code and I can try and point you in the right direction for both the upsert and the extract of records from Salesforce using PHP

  3. #3
    murraybiscuit is offline Junior Member
    Join Date
    Nov 2007
    Posts
    5

    code samples

    Thanks for a speedy response, update() code:

    PHP Code:
    $sObject=new sObject();
      
    $sObject->type='Contact';  
      
    $sObject->Id='id reference here';
    //updating the password, a custom field on the contact object
      
    $sObject->fields["Password__c"]=$_POST['newpass'];
     
    $sObject->fields["Description"]="testing";
     
    //print_r ($sObject);
     
    $result=$mySforceConnection->update($sObject);
     
    //print_r($result);
     
    if($result->success){
      
    $onload.="alert('Thanks. Password updated');";
     }else{
      
    $onload.="alert('".$result->errors[0]->message."');";
     } 
    In terms of the queryMore code, I've come up with a workaround:
    Basically when I get each row of the select result, i check for $result->records[$i]->sobjects, which gives me the nested sobjects and i proceed to add those to a holding array, which I then iterate through to build an html table.

    Excuse my ignorance, but where is the API reference which has the php examples in it? Your posts there seem the most helpful. Well done.

    Take the following code sample excerpt from Creating Email Reports in PHP - ApexDevNet ("working with results" section):

    PHP Code:
    $_id CampaignMember->sobjects[0]->Id;
    $_name $CampaignMember->sobjects[0]->fields->Name;
    $_email CampaignMember->sobjects[0]->fields->Email;
    $_title CampaignMember->sobjects[0]->fields->Title
    Surely lines 1,3 and 4 won't work here, as the object name should be $CampaignMember, not CampaignMember?

    Anyway, any help would be appreciated

  4. #4
    mike's Avatar
    mike is offline Administrator
    Join Date
    May 2007
    Location
    Wylie, Texas
    Posts
    557
    Blog Entries
    15
    Hey MB I just wanted to acknowledge your post and that I will review your questions and try and get back to you today but it may be tomorrow before I can!

    ~Mike

  5. #5
    murraybiscuit is offline Junior Member
    Join Date
    Nov 2007
    Posts
    5

    Thumbs up fixed

    I seem to have solved this: the update() function requires an array of objects as the argument, even if you just have one object to update, add it to an array. In my opinion, the function should check to see if the value it is receiving is an array or not and return an error before it carries on with the rest of the function. I can't see how I received a successful return from this function when it never worked and the argument supplied in the first place was wrong.

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

    Sorry that I did not get a chance to look into this for you and I am glad that you were able to figure it out. I actually could have told you that even if you were updating one item that it had to be an array. I do agree that the function should check to see if the the value it is receiving is an array:

    PHP Code:
     if is_array($value)
    {
       do 
    this
    }
    else
    {
       echo 
    "Your data needs to be in an array, please check data and correct";

    Maybe something like that can be added to your script to check it or maybe you can send that to Nick Tran and he can add it to the next release (whenever that is)

    Do you still need help on the other issue?

    Again sorry for my lack of looking into this

    ~Mike

+ 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