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
A GunaleA Gunale 

Fetch user Address

I have a requirement , Fetch Loggedin User Address in a field.
Any help will be appriciated. 
 
sachinarorasfsachinarorasf
Hi Gunale,

I have gone through your problem.

Here is the query as per the requirement And you can use it. 
 
User userObject = [Select id, Address  FROM User WHERE Id = :UserInfo.getUserId()];
System.debug('userObject-->'+userObject);

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Sachin Arora
ayu sharma devayu sharma dev
Hello Gunale

For this, I would suggest you use formula fields instead of using Apex code as the formula would be easy and efficient.
As you required Address, the address is a combination of many fields like Street Address, State, City, Country, Pincode etc.
So to show the current user Street Address just use the below formula:
$User.Address.Street
You can get Other fields also using the same formula, just replace Street with State, City, Country, and PostalCode. 

I hope it helps you. Please mark this as the best answer if it helps. 
Thanks and Regards
Ayush Sharma