Sample Code :
Id profileId= userinfo.getProfileId();
Id profileId= userinfo.getProfileId();
String profileName=[Select Id,Name from Profile where Id=:profileId].Name;
system.debug('ProfileName'+profileName);
userinfo.getProfileId() function give user`s profile id, use that id and query to profile to get profile name.
Some other UserInfo Methods :
The following are methods for UserInfo. All methods are static.
getDefaultCurrency()
This Function returns default currency code of the context user's for multiple currency organizations OR It can also returns the organization's currency code for single currency organizations.
getDefaultCurrency function returns null for single currency organizations for Apex saved using SalesforceAPI version 22.0 or earlier,.
getFirstName()
This Function returns the context user's first name.
getLanguage()
This Function returns the context user's language.
getLastName()
This Function returns the context user's last name.
getLocale()
This Function returns the context user's locale.
getName()
This Function returns the context user's full name. The format of the name rely on the language preferences specified for that organization.
getOrganizationId()
This Function returns the context organization's ID.
getOrganizationName()
This Function returns the context organization's company name.
getProfileId()
This Function returns the context user's profile ID.
getSessionId()
This Function returns the session ID for the current session.
getTimeZone()
This Function returns the current user’s local time zone.
getUiTheme()
This Function returns the preferred theme for the current user. With the help of this getUiThemeDisplayed () you can check the actual theme displayed to the current user.
getUiThemeDisplayed()
This Function returns the theme being displayed for the current user.
The User.UITheme and User.UIThemeDisplayed global variables and the UserInfo.getUiTheme() and UserInfo.getUiThemeDisplayed() Apex utility methods are improved to support the Salesforce1 mobile app and Lightning Experience.
These system calls and existing variables have expanded the range of return values to support the new user experience contexts. Possible return values include the following:
This is very useful to write Visualforce pages and apps that adapt to the user experience context in which they’re running.
getUserEmail()
This Function returns the current user’s email address.
getUserId()
This Function returns the context user's ID
getUserName()
This Function returns the context user's login name.
getUserRoleId()
This Function returns the context user's role ID.
getUserType()
This Function returns the context user's type.
isCurrentUserLicensed(namespace)
This Function returns true if the context user has a license to the managed package denoted by the namespace. Otherwise, returns false.
isMultiCurrencyOrganization()
Specifies whether the organization uses multiple currencies.
Thank you!!!
Learning Pagination In Salesforce Is Not Difficult At All ! You Just Need 3 Easy Steps
How To Learn Get Field Values From Visualforce Page To Apex Class Controller Without Losing Your Mind
Main Difference Between ISBLANK And ISNULL in Salesforce
How To Get Total Amount Of Records Processed In Batch Job In 10 Minutes And Still Look Your Best
Export VisualForce Data into Excel Sheet in 3 Easiest Steps
7 Easy Steps to Generate Apex Class From WSDL In Salesforce
Simplest Way To Find Number of Days Between Two Dates in Salesforce
3 Easy Steps To Send Emails With Attachment From Your Apex Class In Salesforce
How Insert Comma In Formula Fields Can Help You Improve Your Productivity
Simple Guidance For You In Access Of Subquery Field Value Using Apex - Upwards Traversal.
Access Subquery Field Value Using Apex in 2 Easy Steps- Downwards Traversal
How Learning Enable Inline Editing In Visual Force Pages Could Save Your Money And Time
Enjoy! If you have any questions, comments etc. please feel free to let me know. As always, please feel free to get in touch me as I would be more than happy to assist you with any of your Salesforce development needs.
Some other UserInfo Methods :
The following are methods for UserInfo. All methods are static.
getDefaultCurrency()
This Function returns default currency code of the context user's for multiple currency organizations OR It can also returns the organization's currency code for single currency organizations.
getDefaultCurrency function returns null for single currency organizations for Apex saved using SalesforceAPI version 22.0 or earlier,.
getFirstName()
This Function returns the context user's first name.
getLanguage()
This Function returns the context user's language.
getLastName()
This Function returns the context user's last name.
getLocale()
This Function returns the context user's locale.
getName()
This Function returns the context user's full name. The format of the name rely on the language preferences specified for that organization.
getOrganizationId()
This Function returns the context organization's ID.
getOrganizationName()
This Function returns the context organization's company name.
getProfileId()
This Function returns the context user's profile ID.
getSessionId()
This Function returns the session ID for the current session.
getTimeZone()
This Function returns the current user’s local time zone.
getUiTheme()
This Function returns the preferred theme for the current user. With the help of this getUiThemeDisplayed () you can check the actual theme displayed to the current user.
getUiThemeDisplayed()
This Function returns the theme being displayed for the current user.
The User.UITheme and User.UIThemeDisplayed global variables and the UserInfo.getUiTheme() and UserInfo.getUiThemeDisplayed() Apex utility methods are improved to support the Salesforce1 mobile app and Lightning Experience.
These system calls and existing variables have expanded the range of return values to support the new user experience contexts. Possible return values include the following:
- Theme1—Obsolete Salesforce theme
- Theme2—Salesforce Classic 2005 user interface theme
- Theme3—Salesforce Classic 2010 user interface theme
- Theme4d—Modern “Lightning Experience” Salesforce theme
- Theme4t—Salesforce1 mobile Salesforce theme
- PortalDefault—Salesforce Customer Portal theme
- Webstore—Salesforce AppExchange theme
This is very useful to write Visualforce pages and apps that adapt to the user experience context in which they’re running.
getUserEmail()
This Function returns the current user’s email address.
getUserId()
This Function returns the context user's ID
getUserName()
This Function returns the context user's login name.
getUserRoleId()
This Function returns the context user's role ID.
getUserType()
This Function returns the context user's type.
isCurrentUserLicensed(namespace)
This Function returns true if the context user has a license to the managed package denoted by the namespace. Otherwise, returns false.
isMultiCurrencyOrganization()
Specifies whether the organization uses multiple currencies.
Thank you!!!
More Salesforce Blogs:
Check out Salesforce Daily Limit Only in 5 Simplest StepsLearning Pagination In Salesforce Is Not Difficult At All ! You Just Need 3 Easy Steps
How To Learn Get Field Values From Visualforce Page To Apex Class Controller Without Losing Your Mind
Main Difference Between ISBLANK And ISNULL in Salesforce
How To Get Total Amount Of Records Processed In Batch Job In 10 Minutes And Still Look Your Best
Export VisualForce Data into Excel Sheet in 3 Easiest Steps
7 Easy Steps to Generate Apex Class From WSDL In Salesforce
Simplest Way To Find Number of Days Between Two Dates in Salesforce
3 Easy Steps To Send Emails With Attachment From Your Apex Class In Salesforce
How Insert Comma In Formula Fields Can Help You Improve Your Productivity
Simple Guidance For You In Access Of Subquery Field Value Using Apex - Upwards Traversal.
Access Subquery Field Value Using Apex in 2 Easy Steps- Downwards Traversal
How Learning Enable Inline Editing In Visual Force Pages Could Save Your Money And Time
Enjoy! If you have any questions, comments etc. please feel free to let me know. As always, please feel free to get in touch me as I would be more than happy to assist you with any of your Salesforce development needs.
No comments:
Post a Comment