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
amoldavskyamoldavsky 

Organization administrator email

Hey,

 

I am trying to get the Administrator's email for the given organization from within Apex code. How can I get it?

Is it always gauranteed to be there?

 

It seems to me that there should always be one because when you first register you use a valid real email address which becomes the Admin users for that organization. Later on you can configure sub account that may or may not correlate to real addresses... am I missing something?

 

Thanks!

SFAdmin5SFAdmin5

not really sure what you mean here but you could run some kind of soql query on user object for the sys admin profile id 

 

SELECT Id,Email FROM User WHERE Profile.Name = 'System Administrator'

 

amoldavskyamoldavsky

Hey,

 

But then what if you have a couple Users under the "System Administrator" role? and how do I know which one has a valid email address?

 

I am just trying to get a email address of the ORG administrator (a valid email address).

 

Thanks

amoldavskyamoldavsky

 

I would imagine that the User I am after is the one that was initially used to register for the ORG account because that requires a valid and real email address. Is there a way to get that particular user?