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

get Custom profile names in SOQL

Hi All,


how to get only  Custom profile name in soql query....  whic field am i use in where condition


Select p.UserType, p.UserLicenseId, p.PermissionsViewSetup, p.PermissionsManageUsers, p.PermissionsManageDataCategories, p.PermissionsManageDashboards, p.PermissionsManageCustomReportTypes, p.PermissionsManageChatterMessages,




p.Id,, p.Description, p.CreatedDate, p.CreatedById From Profile p where p.PermissionsViewSetup = true





Suresh RaghuramSuresh Raghuram

you can query directly like this.


select Id, Name from Profile where name =' system Amin';


If this answers your question make this as a solution and give KUDOS.


for getting profile name in SOQL 

use as below 

[select Name from Profile ] ; 


second way if you want to get name of profile of current user without SOQL 

on VF Page



I want only custom profile names through SOQL


can u help any body...


Hi I have found this answer from some discussion on baords and facebook Salesforce community members. 


You can do this first of all you need to find CreatedDate  time of organization and then based of that time and date you can fetch profiles because Standard profile's created Date and time should be same as Organization. 


Datetime DT  = [Select id , CreatedDate from Organization ][0].CreatedDate  ; 

List<Profle>  Profiels = [select id , Name from Profile where CreatedDate = : DT ] ;

Jaiwant PasupuletiJaiwant Pasupuleti
Hi Bondicloud,

I know its been ages since this question is raised. I am hoping this would help someone who is visiting this now...
Assuming that all the profiles that are created by System Admin would be Custom profiles, you can run this query:
[ select id, name from Profile where createdby.Profile.Name = 'System Administrator' ]

This should resolve your issue! Let me know if there's anything I need to learn here!

Thank you! 
Osman ErzincliogluOsman Erzinclioglu

What's interesting about this one is that there is a "custom" column -- with the boolean field set to "true" for all custom profiles -- available in the UI when you're looking over existing profiles (, but that data point isn't available to query against in the developer console.

Also, sadly, neither Sandeep's or Jaiwant's method returned a correct set of results in our instance, so neither method can be depended upon.

Apurv NereApurv Nere
We can use this query:

SELECT Id, Profile.Name FROM PermissionSet WHERE IsOwnedByProfile = true AND IsCustom = true

This will give us the list of all custom profile names. However if you want to get the names of custom profiles created after org creation date then you can try below piece of code:

List<Organization> dateOrg = [select CreatedDate from Organization];
DateTime dtOrgCreation = dateOrg[0].CreatedDate ;
for(Profile prof : [select id,Name from Profile where CreatedDate > :dtOrgCreation ]){
I know this is old, but a simpler way is to query the permissionset.  Every profile is a permission set too, so you can just:
select ProfileID, Profile.Name from PermissionSet where ProfileID <> null and PermissionsConvertLeads = true and (not  Profile.Name like 'system%') And isCustom = true