1

Trying to change the case owner of a specific case by changing the OwnerId value but I am not having any success.. I have compared my query with the docs and I can't understand why it's failing. The examples in the docs are for the Contact object, I could not find examples for Case object but thought it should be the same procedure.

Permissions should not be an issue as I can make updates via workbench on the same field without any problems, however, i'm trying to integrate this with php.

try {
  $caseId = "5004z00001fqUIRAA2";
  
  //query to target specific case to update
  $query = "SELECT CaseNumber,Id,OwnerId FROM Case WHERE Id = '".$caseId."'";

  $queryResponse = $mySforceConnection->query($query);
  $queryResult = new QueryResult($queryResponse);
  echo "<pre>",print_r($queryResult,true),"</pre>";

  //prepare field update
  $sObject = new SObject();
  $sObject->type = 'Case';
  $sObject->fields['OwnerId'] = "0054z000008RuHkAAK";
  $sObject->Id = $caseId;
  
  //submit update
  $updateResponse = $mySforceConnection->update(array($sObject),'Case');
  print_r($updateResponse);


} catch (Exception $e) {
  echo $mySforceConnection->getLastRequest();
  echo $e->faultstring;
}

Here is the response I get on the initial query to confirm I am getting a response back.

QueryResult Object
(
    [queryLocator] => 
    [done] => 1
    [records] => Array
        (
            [0] => stdClass Object
                (
                    [Id] => 5004z00001fqUIRAA2
                    [CaseNumber] => 03161663
                    [OwnerId] => 0054z000007HMzcAAG
                )

        )

    [size] => 1
    [pointer] => 0
    [sf:QueryResult:private] => 
)

However, when performing the subsequent query to update the OwnerId value I get the following error:

INVALID_FIELD: No such column 'fields' on entity 'Case'. 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.

The OwnerId field is not a custom field, it's standard field of the Case object. I even confirmed this field exists within the object.

enter image description here

Any Ideas?

user3436467
  • 1,763
  • 1
  • 22
  • 35

1 Answers1

0

Not much of an answer but too long for a comment.

https://barefoot.sourcerepo.com/barefoot/php_toolkit/trunk/php_toolkit/ looks very old, it references API versions ~20? SF API version is 55-56 now and in fact they plan to kill old versions: https://help.salesforce.com/s/articleView?language=en_US&id=000354473&type=1

Have you just grabbed that (old) sample code or have you downloaded the WSDL file from Salesforce and "consumed" it?

You're dumping the last request only in the catch block - what if you try to dump it anyway, similar to https://help.salesforce.com/s/articleView?id=000383659&type=1

The final XML should be similar to https://developer.salesforce.com/blogs/2015/06/salesforce-soap-api-sample-wsdls "Scenario 8: Updating the ownership of a record using the update() API." Which well, this blog post is from 2015, about 20 API versions old but it's something.

You could also import the WSDL to SoapUI, Postman or what-have-you and experiment with manual calling login, then update in there?

eyescream
  • 18,088
  • 2
  • 34
  • 46