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
ArjunDharArjunDhar 

Account vs Organization

I need to get certain Account details of a User in the Controller.

 

However I find that the "UserInfo" object does not expose any Account Id. It exposes access to organization name and Id.

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_userinfo.htm

 

Q1) Conceptually how is Account different from Organization? (Where is this documented)

Q2) How can I get access to Account Object from the User (assuming Account & Organization are not the same)

 

thanks

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Shashikant SharmaShashikant Sharma
1) How is Account different from Organization :
Organization : It is the key Configuration related to your organization, which means your salesforce org.
Account :
Represents an individual account, which is an organization or person involved with your business (such as customers, competitors, and partners).
2)How can I get access to Account Object from the User
Account can only be fetch from user when user is a portal user. With below code.
User u = [Select ContactId from User where id =: Userinfo.getUserId()];
Contact con = [Select AccountId from Contact where Contactid =: u.ContactId];
Account acc = [Select Name  from Account  where id = c.AccountId];

All Answers

Shashikant SharmaShashikant Sharma
1) How is Account different from Organization :
Organization : It is the key Configuration related to your organization, which means your salesforce org.
Account :
Represents an individual account, which is an organization or person involved with your business (such as customers, competitors, and partners).
2)How can I get access to Account Object from the User
Account can only be fetch from user when user is a portal user. With below code.
User u = [Select ContactId from User where id =: Userinfo.getUserId()];
Contact con = [Select AccountId from Contact where Contactid =: u.ContactId];
Account acc = [Select Name  from Account  where id = c.AccountId];
This was selected as the best answer
ArjunDharArjunDhar

Thanks a lot

 

I would not have guessed that relation between the objects , unless i did a lot of trial and error with objects.

Where are these listed? I have the dev documentation and I did not find it clearly.

 

I also have some other (hopefully last)  questions:

Q3) The Visual Force GLOBAL variables like $User do not have equivalent in the Controller code. Like "UserInfo". Why so? Object conventions should be consistent (specially the global / context related ones).

 

..Also, I see standard Objects in the VF > Setup >Customize > [Standard Objects]. Now the Global Naming convention of VF page Objects (e.g. $User) and those you can use in Controllers (UserInfo) and Standard Objects (like Accounts) are inconsistent. So i feel conceptually disconnected. ..or is there a relaion and API reference that explains it? ..Example : Where does "UserInfo" come from? ..so they just magically explicitly inject it into the context?!?

 

thanks a lot already.

I have the answer to my immediate questions but the additional answers will allow me to search faster through ref material next time.