0

I'm new to Salesforce and SOQL but not PHP and SQL, therefore this question is a little odd to myself that I can't figure it out.

The Enterprise SOQL query runs fine and presents the desired results when ran in Force.com Explorer, but when running through the PHP Toolkit I'm not getting any data from the Order table (it's executing but not producing data). When I request data from Account, it comes through fine.

Works:

$query = "SELECT Id, Name, BillingCity, BillingStreet, BillingState, BillingPostalCode, LastModifiedDate from Account LIMIT 10"; // WHERE Id = '".$orderInfo->AccountId."'";
$response = $mySforceConnection->query($query);

echo "Results of query '$query'<br/><br/>\n";
foreach ($response->records as $record) {
    echo $record->Id . ": " . $record->Name . " (".$record->LastModifiedDate.")<br/>\n";
    echo "Address:<br/> ";
    echo $record->BillingStreet . "<br/>" . $record->BillingCity .", " . $record->BillingState . " " . $record->BillingPostalCode . "<br/><br/>\n";
}

Doesn't work:

$query = "SELECT AccountId, Status, StatusCode, SystemModstamp FROM Order LIMIT 10";
    $response = $mySforceConnection->query($query);

    echo "Results of query '$query'<br/><br/>\n";
    foreach ($response->records as $record) {
        echo "<b>" . $record->AccountId . ": " . $record->SystemModstamp ."<br/>\n";
    }

print_r results

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

    [1] => stdClass Object
        (
            [Id] => 
        )

    [2] => stdClass Object
        (
            [Id] => 
        )

    [3] => stdClass Object
        (
            [Id] => 
        )

    [4] => stdClass Object
        (
            [Id] => 
        )

    [5] => stdClass Object
        (
            [Id] => 
        )

    [6] => stdClass Object
        (
            [Id] => 
        )

    [7] => stdClass Object
        (
            [Id] => 
        )

    [8] => stdClass Object
        (
            [Id] => 
        )

    [9] => stdClass Object
        (
            [Id] => 
        )

)

Update 2/20/14

I've been able to progress only a little bit more forward, I'm now able to retrieve the ID of an OrderItem using the following:

Results of query 'SELECT of_Applicants__c, Ad_Comments__c, Ad_Picklist__c, Ad_Expiration_Date__c, Ad_Start_Date__c, Ad_Title__c, Ad_Type__c, Blind_Ad__c, CreatedById, CreatedDate, IsDeleted, LastModifiedById, LastModifiedDate, ListPrice, OrderId, Id, OrderItemNumber, OriginalOrderItemId, Description, PricebookEntryId, Private_Dashboard__c, Quantity, SystemModstamp, UnitPrice FROM OrderItem LIMIT 10'

Array ( [0] => stdClass Object ( [Id] => 802d000000000XZAAY ) [1] => stdClass Object ( [Id] => 802d000000000YhAAI ) [2] => stdClass Object ( [Id] => 802d000000000Z6AAI ) [3] => stdClass Object ( [Id] => 802d000000000ZuAAI ) [4] => stdClass Object ( [Id] => 802d000000000ZzAAI ) [5] => stdClass Object ( [Id] => 802d000000000bvAAA ) [6] => stdClass Object ( [Id] => 802d000000000cKAAQ ) [7] => stdClass Object ( [Id] => 802d000000000cjAAA ) [8] => stdClass Object ( [Id] => 802d000000000XeAAI ) [9] => stdClass Object ( [Id] => 802d000000000aJAAQ ) ) 

Any advice?

0
0

The solution to my problem was simple. As far as I read within the manual for the PHP Toolkit, it doesn't mention downloading your organization specific WSDL file, which is essential for all objects to load correctly within the toolkit.

Solution

  • Navigate to Setup | Develop | Download your organization-specific WSDL
  • Choose the correct WSDL file to download. In my case, it was Enterprise WSDL
  • Select package versions to include in WSDL file, click Generate
  • If the file opens in your browser, right click and click View Source
  • Select All and Copy the XML to a new file called my.wsdl.xml, upload to your soapclient directory
  • Change your PHP script's createConnection() function from enterprise.wsdl.xml to my.wsdl.xml
  • Test your script

Note

You may not need to change the name of the file. In my case, I had to, because the old XML file was being cached by the server.

References

Full instructions to generate your WSDL file:

https://www.salesforce.com/developer/docs/api/Content/sforce_api_quickstart_steps_generate_wsdl.htm

-1

If your query is correct but not getting the data you were expecting, typically the issue is around security. Understanding how Security works in Salesforce, would greatly help you troubleshoot the issues. Here is a great series from Salesforce.

2
  • Thank you, I'll look into this tomorrow then. But what strikes me as odd, is the fact that I can run the query anywhere else, either in Force.com Explorer or ApexDataLoader, and it executes just fine, leading me to believe that I am setup with the correct permissions...
    – ITAdminNC
    Feb 20 '15 at 6:41
  • I've looked into security, and I am pretty positive it is setup correctly. Any other suggestions?
    – ITAdminNC
    Feb 20 '15 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.