You need to sign in to do that
Don't have an account?

cannot access custom fields on custom objects via api
I have a custom object in our Salesforce setup called AgentProducts, when I do a query (code running in php) via the API the only field I can get back is Id;
select Id, User_Id__c from AgentProducts__c
returns a record for every one of the entries in AgentProducts, but only with the Id field;
Array
(
[0] => stdClass Object
(
[Id] => a0350000008xWWKAA2
)
[1] => stdClass Object
(
[Id] => a0350000008xWWLAA2
)
etc.
Even worse, if I filter the query by something like my custom email field, I get back the correct Id for the correct account, but still, no further data;
select Id, User_Id__c from AgentProducts__c where Email__c='xxx@xxxxx.xxx'
returns:
stdClass Object
(
[Id] => a0350000008xWWMAA2
)
Any ideas? I've been looking through the online documentation but I can't find anything on custom objects needing special treatment.
Thanks for your reply.
I have checked the permissions. What I checked was under
Administration Setup ->
Manage Users ->
Profiles
Then the particular profile is the Admin,and under his Custom Object Permissions all of the check boxes (Read, Create, Edit, Delete, View All, Modify All) are checked off.
Are these the permissions you mean?
I also noticed that some other threads on similar topics recommended updating the enterprise WSDL. We did that as well but I am still having the same problem.
this query returns a record with an ID that is correct for the email
select Id, Email__c, User_Id__c from AgentProducts__c where Email__c='xxxx@xxxx.com'
but it only returns the Id.
thank you for your help
Got it to work.
The problem was that the WSDL file that comes with the Toolkit doesn't include all the custom object fields, so I needed a version of the WSDL file that had my custom objects in it - basically a "personalized" version of that file. I got it by going to Setup >> Develop >> API, and then there's an option to get the WSDL file. I was using the enterprise WSDL file, so I downloaded that version, and sure enough, it included all the custom objects and their fields.
I overwrote the old WSDL file (mine was in the soapclient folder) with it (I had to view the page source first to see the real content, since my browser tried to show me the file instead of downloading it) and then copied all of that content into the old WSDL file.
One small thing I noticed - if a field has not been filled in (for example, I had a set of optional custom fields that most records didn't use), then the field does not come back in the recordset, even if I explicity added that field into the SELECT query.
Hope this helps.
Further to the above solution, you might also want to make sure that your WSDL is not caching by adding the following code before you create a Salesforce Connection through SOAP. This was the missing piece in my puzzle.
Not my solution, just pasting it everywhere where I found half the answer. Thanks all.
Also I would not use the Enterprise WSDL, I always use the partner WSDL. it is a lot more felxible!!
~Mike
Thank you so much for this!!!!!!!!!!!!!!!!!!!! I was going crazy trying to work out why I couldn't see my custom fields in the API. THANK YOU!
<?php
// SOAP_CLIENT_BASEDIR - folder that contains the PHP Toolkit and your WSDL
// $USERNAME - variable that contains your Salesforce.com username (must be in the form of an email)
// $PASSWORD - variable that contains your Salesforce.ocm password
define("SOAP_CLIENT_BASEDIR", "../soapclient");
ini_set("soap.wsdl_cache_enabled", "0");
$USERNAME='ranjeet.ghola11ve@done.com';
$PASSWORD="ranjeet11donec10bhQzwkIQd28sWldfhmuYN2";
//require_once (SOAP_CLIENT_BASEDIR.'/SforcePartnerClient.php');
require_once (SOAP_CLIENT_BASEDIR.'/SforceEnterpriseClient.php');
require_once (SOAP_CLIENT_BASEDIR.'/SforceHeaderOptions.php');
require_once (SOAP_CLIENT_BASEDIR.'/SforceBaseClient.php');
try
{
$mySforceConnection = new SforceEnterpriseClient();
$mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
$mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);
$query = "SELECT Id,FirstName,LastName,Email,Mychance__c FROM Contact";
$queryResult = $mySforceConnection->query($query);
$records = $queryResult->records;
echo "<pre>";
print_r($records);
echo "</pre>";
} catch (Exception $e) {
echo "<pre>";print_r($e);echo "</pre>";
}
?>
can't get the custom value of Mychance__c field . And in contact that Mychance__c is also not empty.
I use upadated enterprise file.
and also
ini_set("soap.wsdl_cache_enabled", "0"); whats wrong in my code. i am using developer edition . Please Help
Thanks!
$mySforceConnection = new SforcePartnerClient();
$mySoapClient = $mySforceConnection->createConnection('partner.wsdl.xml');
$mylogin = $mySforceConnection->login($USERNAME, $PASSWORD);
$query = "SELECT Id,Name__c,Phone__c from CustomObje__c;
$response = $mySforceConnection->query($query);
$queryResult = new QueryResult($response);
print_r($queryResult->current());
This will return single record entry, you can use it in loop as well to get all the records. This is working perfectly for me.
sOBJECT.GetType().GetProperty(FIELDNAME.ToString()).GetValue(sOBJECT)
For partner WSDL you need to phase the XML which is described in sOBJECT.Any