Unable to query the `Name` property in Salesforce objects using SOAP

83 Views Asked by At

I'm trying to call the Salesforce API using SOAP and PHP. I was able to successfully login and retrieve the data. But when i query for the Name property I'm unable retrieve it. I am using Windows Azure VM and IIS as the server. The user has full access over the objects.

Why cant i query the Name but the Id only? What am i doing wrong here?

Following is the code i used..

config.php
<?php

    ini_set('display_errors',1);
    ini_set('error_reporting', E_ALL);
    // error_reporting(E_ALL ^ E_WARNING); 

    require ('sf-toolkit/soapclient/SforceEnterpriseClient.php');

    define("USERNAME","[email protected]");
    define("PASSWORD","xxx123*");
    define("SECURITY_TOKEN","dyv09uqXkeU5rik");

    $mySforceConnection = new SforceEnterpriseClient();
    $mySforceConnection->createConnection("sf-toolkit/soapclient/enterprise.wsdl.xml");
    $mySforceConnection->login(USERNAME,PASSWORD.SECURITY_TOKEN);

?>

.

    require ('config.php');
    try{
        //$query = "SELECT Id FROM Employee__c limit 3";
        $query = "SELECT Name from Employee__c limit 3";

        $response = $mySforceConnection->query($query);

    foreach ($response->records as $record) {
        echo '<pre>';
        print_r($record);
        print_r("<br>");
        echo '</pre>';
    }

print_r($response->records);
   }
   catch (Exception $e){
       print_r($mySforceConnection->getLastRequest());
       echo $e->faultstring;
       }
?>

Following is the output...

stdClass Object
(
    [Id] => 
)

stdClass Object
(
    [Id] => 
)

stdClass Object
(
    [Id] => 
)

Array ( [0] => stdClass Object ( [Id] => ) [1] => stdClass Object ( [Id] => ) [2] => stdClass Object ( [Id] => ) ) 

But when i query the Id, following is the output...

stdClass Object
(
    [Id] => a1I14000008JFvrEAG
)

stdClass Object
(
    [Id] => a1I14000008JFvDEAW
)

stdClass Object
(
    [Id] => a1I14000008JFvXEAW
)

Array ( [0] => stdClass Object ( [Id] => a1I14000008JFvrEAG ) [1] => stdClass Object ( [Id] => a1I14000008JFvDEAW ) [2] => stdClass Object ( [Id] => a1I14000008JFvXEAW ) ) 
1

There are 1 best solutions below

0
On

You should ensure that the profile of the user used in making the request has access to the Name field on the Employee__c Object