SalesForce API query doesn't show custom fields
Asked Answered
M

2

6

I have a custom date field for accounts in SalesForce: LastCheckedDate (API Name: LastCheckedDate__c)

I'm trying to use the SalesForce Enterprise API to query accounts based on that field. It returns results, and I can use the custom field in the WHERE part of the query, but I can't get it to actually show me the value of the custom field in the results.

This PHP code should get me the ID, name, and LastCheckedDate of any account that has been checked in 2011:

$query = "SELECT Id,Name,LastCheckedDate__c FROM Account WHERE LastCheckedDate__c > 2011-01-01";
$response = $salesforceConnection->query($query);

foreach ($response->records as $record) {               
    print_r($record);
}

It correctly only returns accounts that have been checked in 2011, but the result doesn't include the value of that custom field:

stdClass Object
(
    [Id] => 0015000000abcdefgh
    [Name] => Bob's Widget Factory
) 

How can I get it to include the LastCheckedDate in the results objects?

Mckenziemckeon answered 23/5, 2011 at 23:3 Comment(1)
I am having the same exact problem as this. I have an update to date WSDL and I know my code is correct because it worked perfectly in TEST. Moved to Prod, updated WSDL and it just doesn't show custom fields.Sennit
P
4

Seems like you are having the same problem as is addressed in this question: SalesForce.com: Retrieve custom fields via PHP.

It is related to how you are parsing the returned data.

Phytology answered 23/5, 2011 at 23:22 Comment(1)
Ahhh...it wasn't how I was parsing the results, but that thread pointed me in the right direction - I needed to generate an updated enterprise.wsdl.xml with the new custom field. Thanks!Mckenziemckeon
O
7

Update your wsdl file. So You can not select or update any field that are not in the wsdl file.

Ozonide answered 16/8, 2012 at 12:30 Comment(2)
What does your answer improve on the accepted one? This should be a comment, not an answerWaldrop
Actually, it was very useful one. After I regenerated my wsdl file my custom fields started showing up not just the Ids. ref: github.com/developerforce/Force.com-Toolkit-for-PHP/issues/52Gourley
P
4

Seems like you are having the same problem as is addressed in this question: SalesForce.com: Retrieve custom fields via PHP.

It is related to how you are parsing the returned data.

Phytology answered 23/5, 2011 at 23:22 Comment(1)
Ahhh...it wasn't how I was parsing the results, but that thread pointed me in the right direction - I needed to generate an updated enterprise.wsdl.xml with the new custom field. Thanks!Mckenziemckeon

© 2022 - 2024 — McMap. All rights reserved.