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
ringnengringneng 

Working with API, Picklist values null when executing query.

Hey guys, I've lurked the forums in search of an answer but haven't found anything that could help me, and my problem seems so stupid I just can't figure it out.

 

I'm working with the PHP toolkit. Works like a charm except I'm querying for my Case sObject records. I created a custom field named Customer_Portal_User__c, that is a lookup relationship type field to a User__c object.

 

One would figure this code would be enough...

 

Query and result validation function:

 

public function getCasesByAccount($logged_acct, $connection) {
$query = "SELECT AccountId, Id, Customer_Portal_User__c, CaseNumber, Origin, Reason, Type, Category_Identifier__c, Client_Reference__c, Description, Subject, Priority, Status, OwnerId FROM Case WHERE Status IN ('New', 'Updated by Customer') AND AccountId = '".$logged_acct."'"; try { $response = $connection->query($query); } catch (Exception $e) {} if (count($response->records) >= 1) { return $response; } else { return "No cases under this account."; } }

 

And this is how I call my function and go through the records.

 

$acctCases = $salesforceDML->getCasesByAccount($logged_acct, $connection);
foreach ($acctCases->records as $record) {
echo "<div class='row'>";
echo "<div class='span-3'><a href='view_case.php?id=".$record->Id."'>View</a></div>";
echo "<div class='span-9'>".'Lalala'.$record->Customer_Portal_User__c."</div> ";
echo "<div class='span-6'>".$record->Subject."</div> ";
echo "<div class='span-9'>".$record->Type."</div> ";
echo "</div>";
}

 

 

Which outputs All of the fields, EXCEPT Customer_Portal_User__c:

 

if I var_dump the $record variable from the foreach, I get the following...

 

object(stdClass)#16 (10) { ["Id"]=> string(18) "500e0000000UZmkAAG" ["AccountId"]=> string(18) "001e0000003FQsSAAW" ["CaseNumber"]=> string(8) "00026957" ["Description"]=> string(5) "fghgh" ["Origin"]=> string(5) "Phone" ["OwnerId"]=> string(18) "005a0000008678DAAQ" ["Priority"]=> string(23) "4 - Feature Enhancement" ["Status"]=> string(3) "New" ["Subject"]=> string(5) "hgfhg" ["Type"]=> string(10) "Activation" }

 

THE FIELD ISN'T EVEN THERE!!! ALLLLLLLLLLLLLLLLLLLLLLLLLLLLL the fields are returned except THAT one. CHRISTTT. This is RIDICULOUS.

 

I've even tried swapping the $query from my function for this, but the same results.

 

$query = "SELECT FirstName__c, LastName__c, Account__c, 
				(SELECT Id, Subject, Customer_Portal_User__c from Cases__r)
				FROM User__c";

 

I just don't know anymore. Any suggestions? 

 

Best Answer chosen by Admin (Salesforce Developers) 
arizonaarizona

My guess is that it is a permissions issue.  The field or user object is not accessible to the api user.

All Answers

arizonaarizona

My guess is that it is a permissions issue.  The field or user object is not accessible to the api user.

This was selected as the best answer
ringnengringneng

I double checked permissions, how could I forget. Thank you very much!