+ Start a Discussion
SoCal AdminSoCal Admin 

Cannot access ID field in returned recordset

 

Does anyone see anything wrong with this?  This is bizarre.  If I replace the field "id" with "Name", it works fine.  ID is clearly listed in the return results.  But I cannot assign or read the value using standard syntax.  Originally, I had one PRINT statement with 2 references ( ->Name and -> Id), Trying to figure it out, I created the top 2 variable assignments hoping that the failure was related to PRINT and not to ASSIGNMENT - but no - it fails everywhere.

 

The query works fine and any reference to the returned record set using NAME works fine - but I can't access the ID field.

 

 $query = "SELECT Id,Name from MycustomObject__c where somevalue=something;  // Query works FINE -> Don't look here

 

            $id = $r->records[0]->fields->Id;       // This DOESN'T WORK     ***
            $id = $r->records[0]->fields->Name;     // This works fine.

 

            print "<ul>Found Job Number " . $arr[8] . " in Project " . $r->records[0]->fields->Name . " / id=" . $id . "</ul>";

 

 

Here is the result from print_r:

 

QueryResult Object ( [queryLocator] => [done] => 1 [records] => Array ( [0] => SObject Object ( [type] => MycustomObject__c [fields] => stdClass Object ( [Name] => Samptom Excelite ) [Id] => a1DE0000000yRAINAM ) ) [size] => 1 )