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

Accessing a field name or label

I am trying to write some trigger code and I need to access the field names of some of our custom fields.  I have a custom field named "Users" on the account level, and I want to create a string that contains the actual name of the field if it changed. However I don't know how to access a field's name (custom or otherwise).  I tried But this did not work.  Is this possible?
Here is my trigger code:

if (Trigger.old.Users__C !=


String whatChanged = 'Changed '+ +' from '+ Trigger.old.Users__C + ' to ' +;



You can not access describe information from Apex Code currently.

If you want to present an error to the user you could add an error in this fashion which will show in the expected location on the edit page:'You can't change the value for this field.');
I noticed the date of this post and was wondering...

Are we now able to access field names/labels in apex code?

I want to create a visual force page that mimics the views page.
I  want to put the field names into a select box. If the field name is selected
then I can pass it to a method in the page's controller to dynamically create
the where part of the query.

Thank you in advance!