salesforcesalesforce-lightningsoql

How to retrieve the person's name instead of its Id?


Inside the "Case" table, there is a column called "OwnerId" and if I use "SELECT Owner.Name" I can extract the person's name instead of its "Id".

The same "Case" table has another column called "Secondary_Owner__c" which has the same "Ids" as the above "OwnerId" column. How can I make a query to return the person's name instead of its "Id" from "Secondary_Owner__c" similarly I did for the "OwnerId".


Solution

  • SELECT Secondary_Owner__r.Name FROM Case

    For custom fields access via dot you add "__r" like you add "__c" if you want that field's value. For more info check topics under https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_relationships.htm