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
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
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: 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