You need to sign in to do that
Don't have an account?
bdensmore
Can't display Custom Field Values
I'm trying to grab data from a custom field on my Contact object in PHP but for some reason it always comes back empty. In my query I can filter on that field and using the SOQL Explorer if I run the same query I see the value for that field. Is there something special I need to do to get the value of a special field?
This is my code, the ID field shows up fine but not the custom_field__c.
try {
$mySforceConnection = new SforceEnterpriseClient();
$mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
$mylogin = $mySforceConnection->login("mylogin", "mypassword");
$query = "Select Id,custom_field__c From Contact where custom_field__c != null";
$options = new QueryOptions(10);
$mySforceConnection->setQueryOptions($options);
$response = $mySforceConnection->query($query);
!$done = false;
$RecordNum = 0;
echo "Size of records: ".$response ->size."<br />";
if ($response->size > 0) {
while (!$done) {
foreach ($response->records as $record) {
$RecordNum = $RecordNum + 1;
echo $RecordNum.". ".$record->Id." - ";
echo $record->custom_field__c."<br />";
}
if ($response->done != true) {
try {
$response = $mySforceConnection->queryMore($response->queryLocator);
} catch (Exception $e) {
print_r($mySforceConnection->getLastRequest());
echo $e->faultstring;
}
} else {
$done = true;
}
}
}
} catch (Exception $e) {
print_r($mySforceConnection->getLastRequest());
echo $e->faultstring;
}
This is my code, the ID field shows up fine but not the custom_field__c.
try {
$mySforceConnection = new SforceEnterpriseClient();
$mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/enterprise.wsdl.xml');
$mylogin = $mySforceConnection->login("mylogin", "mypassword");
$query = "Select Id,custom_field__c From Contact where custom_field__c != null";
$options = new QueryOptions(10);
$mySforceConnection->setQueryOptions($options);
$response = $mySforceConnection->query($query);
!$done = false;
$RecordNum = 0;
echo "Size of records: ".$response ->size."<br />";
if ($response->size > 0) {
while (!$done) {
foreach ($response->records as $record) {
$RecordNum = $RecordNum + 1;
echo $RecordNum.". ".$record->Id." - ";
echo $record->custom_field__c."<br />";
}
if ($response->done != true) {
try {
$response = $mySforceConnection->queryMore($response->queryLocator);
} catch (Exception $e) {
print_r($mySforceConnection->getLastRequest());
echo $e->faultstring;
}
} else {
$done = true;
}
}
}
} catch (Exception $e) {
print_r($mySforceConnection->getLastRequest());
echo $e->faultstring;
}
echo $sObject->fields->custom_field__c;
I'm having the same issue using the PHP Toolkit. I've created a custom field in the lead object, but when I try to query a record and display a custom field I can't see the custom field in the results: ( im simply using a SOQL query )
Anyone got any tips?
thanks for your reply, the cache turned out to be the problem yes, I solved it by switching the toolkit to use a file named without the .xml extension thus invalidating the cache.
Cheers
Andy