You need to sign in to do that
Don't have an account?
ryandevito
Accessing Custom Objects via PHP SOQL call
Using the SOQL commander I am able to query and retrieve values from fields within custom objects without issue.
When I try to use the same exact query from PHP I get "Notice: Undefined property: SObject::$Date_Requested__c in /var/www/........"
..... where date_requested__c is one of the custom fields I'm trying to pull.
How come I cannot retrieve values from the API like I can using the SOQL commander SQL dashboard?
Is querying custom fields from the API not allowed?
Thanks in advance,
Ryan
I figured out that the problem was I was logged in using my developer force account, instead of my regular salesforce account. Thus, the wsdl files were different. Once I turned off the wsdl caching in php and re-downloaded the appropriate wsdl file, it worked fine.
Thanks!
All Answers
Hi Ryan,
This sounds like a problem with your WSDL file.
You can probably solve it by either
(a) using the partner WSDL file or
(b) regenerating a new enterprise WSDL file
partner is loosely typed, so it should be ok with queries containing all objects and fields, but enterprise is strongly typed, so it requires you regenerate it anytime you add new objects or fields.
Check out the docs: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_partner.htm
best
-paul
Hi Paul
Thanks for the prompt response. I refreshed the enterprise WSDL, however this did not solve the problem. I expected this, because the objects are not new, but rather have been around for months now.
It seems very odd since I'm using the exact same query that I ran in the SOQL commander, just in my PHP code. My code is below for reference:
$query = "
SELECT
Date_Resource_Requested__c,
Network_or_Advertiser_Id__c,
Contract_Type__c,
Contract_Date__c,
Client_Name__c,
Client_email_address__c
FROM
SFDC_Request__c
WHERE
Id='{$request_id}'";
$response = $sf_connection->query($query);
print_r($response);
When I print_r the $response object, (aside from the object not defined error messages) I see the following:
Notice: Undefined property: SObject::$Date_Resource_Requested__c in ... on line 42 Notice: Undefined property: SObject::$Network_or_Advertiser_Id__c in ... on line 43 Notice: Undefined property: SObject::$Contract_Type__c in ... on line 44 Notice: Undefined property: SObject::$Contract_Date__c in ... on line 45 Notice: Undefined property: SObject::$Client_Name__c in ... on line 46 Notice: Undefined property: SObject::$Client_email_address__c in ... on line 47
I figured out that the problem was I was logged in using my developer force account, instead of my regular salesforce account. Thus, the wsdl files were different. Once I turned off the wsdl caching in php and re-downloaded the appropriate wsdl file, it worked fine.
Thanks!
QueryResult Object
02(
03 [queryLocator] =>
04 [done] => 1
05 [records] => Array
06 (
07 [0] => SObject Object
08 (
09 [type] =>
10 [fields] =>
11 )
12
13 )
14
15 [size] => 1
16)
Does anyone have a solution?