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
cyrilvercyrilver 

Account Owner label instead of OwnerId label

Hi,

 

In apex whit "schema.SObjectType.Account.fields.getMap()" you can recover all information on Account Fields.

Then the getLabel() can return the label of each field.

My problem is that I can recover the label of the "OwnerId" field but I wan't to get the "Account Owner" label.

I try the method "getRelationshipName()" but it only returns the name of the relation and not the label.

Many thanks.

 

Regards,

Cyril

Navatar_DbSupNavatar_DbSup

Hi,

 

In Account API the Account owner field is referenced by onwerid.

 

For more detail follow below link:

 

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_account.htm

 

You can create a logic in your code for displaying 'Account Owner' instead of 'Owner ID'

 

Try the below code snippet as reference:

 

Schema.DescribeSObjectResult r = Account.sObjectType.getDescribe();

Schema.DescribeFieldResult f = Schema.sObjectType.Account.fields.ownerid;

system.debug('@@@@@@@@@2'+f.getLabel());

if('Owner ID'==f.getLabel())

{

    system.debug('Account Owner');

}

 

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

 

cyrilvercyrilver

This is the problem I have.

I would find a solution to recover the label "Account Owner" in the metadata and not the "Owner Id" label.

This is the same problem with the field "AccountId" on Contact --> i would find a solution to recover the label "Account Name" and not "Account Id" --> For that I can do f.getLabel() on the Account object but I don't find any solution for the field "OwnerId"

Maybe something like f.getRelationshipName().getLabel() ---> this does not exist.

Hope you can help me !

 

Cyril