You need to sign in to do that
Don't have an account?

user custom field details
String userId = UserInfo.getUserId();
User u;
u=[SELECT Id, User_Pos__c FROM User WHERE Id =:userId limit 1];
String userPos = u.User_Pos__c;
I want custom field value in my string please suggest.
How you want exactly?
In your code, if the datatype of your custom field is String then you are doing it absolutely correct.
If the datatype of User_Pos__c field is something else then you can use the following method to convert its value into a string.
String userPos = String.valueOf(u.User_Pos__c);
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too
Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com
Here is the correct solution to your problem. Please replace all of your above code with these lines of codes. It will work in both cases whether it is string type or another type. I hope it may help you surely.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com (http://www.ajaydubedi.com )