function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Peter KayePeter Kaye 

Select query only retrieves Id field

I have a php script that retrieves Salesforce data from a number of objects  without issue.  I have just added a new custom object which  currently only retrieves the id field from simple SQL like:
$query = "SELECT id, IsDeleted, Name from Normal_Service__c ";

Here is  result of printing out $result
 
QueryResult Object
(
    [queryLocator] => 
    [done] => 1
    [records] => Array
        (
            [0] => stdClass Object
                (
                    [Id] => a0W58000005yWfMEAU
                )

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

        )

I have re-built the Enterpise WSDL for the new object  Normal_Service__c:
 
<complexType name="Normal_Service__c">
<complexContent>
<extension base="ens:sObject">
<sequence>
<element name="AttachedContentDocuments" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="AttachedContentNotes" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="Attachments" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="Attendance__c" nillable="true" minOccurs="0" type="xsd:double"/>
<element name="Children__c" nillable="true" minOccurs="0" type="xsd:double"/>
<element name="CombinedAttachments" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="Communicants__c" nillable="true" minOccurs="0" type="xsd:double"/>
<element name="ContentDocumentLinks" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="CreatedBy" nillable="true" minOccurs="0" type="ens:User"/>
<element name="CreatedById" nillable="true" minOccurs="0" type="tns:ID"/>
<element name="CreatedDate" nillable="true" minOccurs="0" type="xsd:dateTime"/>
<element name="DuplicateRecordItems" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="Emails" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="Envelopes__c" nillable="true" minOccurs="0" type="xsd:double"/>
<element name="EventRelations" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="FeedSubscriptionsForEntity" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="IsDeleted" nillable="true" minOccurs="0" type="xsd:boolean"/>
<element name="LastModifiedBy" nillable="true" minOccurs="0" type="ens:User"/>
<element name="LastModifiedById" nillable="true" minOccurs="0" type="tns:ID"/>
<element name="LastModifiedDate" nillable="true" minOccurs="0" type="xsd:dateTime"/>
<element name="LastReferencedDate" nillable="true" minOccurs="0" type="xsd:dateTime"/>
<element name="LastViewedDate" nillable="true" minOccurs="0" type="xsd:dateTime"/>
<element name="Leader_Comments__c" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="LookedUpFromActivities" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="Music_Person__c" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="Music__c" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="Name" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="Notes" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="NotesAndAttachments" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="Owner" nillable="true" minOccurs="0" type="ens:Name"/>
<element name="OwnerId" nillable="true" minOccurs="0" type="tns:ID"/>
<element name="Plate__c" nillable="true" minOccurs="0" type="xsd:double"/>
<element name="ProcessInstances" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="ProcessSteps" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="Readers__c" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="RecordAssociatedGroups" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="Refreshments__c" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="Sermon_Key_Points__c" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="Sermon_Title__c" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="Service_Notices__c" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="Service_Readings__c" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="Service_Set_Up__c" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="Service_Taster__c" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="Service__c" nillable="true" minOccurs="0" type="tns:ID"/>
<element name="Service__r" nillable="true" minOccurs="0" type="ens:Service3__c"/>
<element name="Sidespersons__c" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="SystemModstamp" nillable="true" minOccurs="0" type="xsd:dateTime"/>
<element name="TaskRelations" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="TopicAssignments" nillable="true" minOccurs="0" type="tns:QueryResult"/>
<element name="UserRecordAccess" nillable="true" minOccurs="0" type="ens:UserRecordAccess"/>
</sequence>
</extension>
</complexContent>
</complexType>

Any thoughts on what I might be doing wrong ?  Thanks.

 
Best Answer chosen by Peter Kaye
Peter KayePeter Kaye
The problem has now disappeared with no changes to the script code.  

I can only conclude that this is a SF Server issue related to the way a new WSDL is mirrored around the server cluster that handles API requests.  I now realise I had a clue here - the very first time I ran the script, even the Id field was blank - then after a few minutes the Id field appeared as shown above.

I can't be sure how long it was before this problem went away as I moved on to other things for most of the last 24 hours,  but it was certainly more than 2 hours that I was seeing the curious script response on new objects added to the WSDL.  Quite why it managed to retrieve the correct Id field and not any other fields is strange.

The take-away for me here is if you add new objects to the WSDL then you may need to wait 1 hour or more before being able to access the full object data via the API.  

All Answers

Peter KayePeter Kaye
The issue must be related to the new object  because if I change the object name in the SQL, leaving all the other code unaltered,, all the query fields appear.  
My query statement is:
$response = $mySforceConnection->queryAll($query);
If I got no data back I'd suspect the WSDL, but to just get the Id and not another standard field like Name is really puzzling.


 
Peter KayePeter Kaye
It  isn't just the object referred to above. Any new objects added produce the same result.   Yet existing objects display data correctly.  These objects were created in  October 2010.  Is there some issue with the Soap Client in  the latest release (2010) of the php Developer Kit and a WSDL produced in the current SF release ?   Any help here much appreciated. 
Peter KayePeter Kaye
The problem has now disappeared with no changes to the script code.  

I can only conclude that this is a SF Server issue related to the way a new WSDL is mirrored around the server cluster that handles API requests.  I now realise I had a clue here - the very first time I ran the script, even the Id field was blank - then after a few minutes the Id field appeared as shown above.

I can't be sure how long it was before this problem went away as I moved on to other things for most of the last 24 hours,  but it was certainly more than 2 hours that I was seeing the curious script response on new objects added to the WSDL.  Quite why it managed to retrieve the correct Id field and not any other fields is strange.

The take-away for me here is if you add new objects to the WSDL then you may need to wait 1 hour or more before being able to access the full object data via the API.  
This was selected as the best answer