How often does the letter o occur in:
Q: toLabel(RecordType.Name) and RecordType.Name in the same SOQL query How to use toLabel(RecordType.Name) and RecordType.Name in the same SOQL query?
I am trying to retrieve both the values and use them. If I can get the query to work then how can I refer the values from the result?
List<Case> csList = [Select Id, RecordType.Name, toLabel(RecordType.Name) RName
                         From Case limit 10];

When I execute the above code in the developer console I get the below error
System.QueryException: No such column RName on entity RecordType. If you are attempting to use a custom field, be sure to append the __c after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

I tried another approach and the query worked but I am unable to use the toLabel(Status) value. How can I use it?
String soql =  SELECT Id, RecordType.Name, toLabel(RecordType.Name) StatusLabel, Description 
          +  FROM Case ORDER BY CreatedDate DESC LIMIT 100;

// Query the cases object
List<Case> cases = Database.query(soql);
for (Case cs : cases) {
  system.debug(cs.get(StatusLabel));  
}

When I try to display the translated record type name I get the following error
System.SObjectException: Invalid field StatusLabel for Case


A: You cant use both the API value and translated value on the same field in the same query. Its not possible to alias the fields either, and aliases only have an effect in aggregate queries. You would need two different queries. In both cases, they would be referenced by the field name (e.g. cs.RecordType.Name).

A: you were nearly the solution.
Here are the code to get what you want:
String soql =  SELECT Id, RecordType.Name, toLabel(RecordType.Name) 
StatusLabel, Description 
      +  FROM Case ORDER BY CreatedDate DESC LIMIT 100;

// Query the cases object
List<Case> cases = Database.query(soql);
for (Case cs : cases) {
  system.debug(cs.RecordType.get(StatusLabel));  
}

You must add the RecordType (Parent relation name) to get the alias field.
It worked for me on custom objects.
Hope this helps you.

A: List<Case> csList = [Select Id, RecordType.DeveloperName, toLabel(RecordType.Name)
                     From Case limit 10];

Above query will give me the original value (since DeveloperName and Name hold the same value) and also the translated value.

user
The total number of "o"s in that passage is one hundred and sixteen.
assistant