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

Profile Name changes based on user language?



I've written a test that creates a new user using the system admin profile. I select the proflie with this query in my test 


Profile p = [SELECT Id,Name FROM Profile WHERE Name='System Administrator'];


The problem is that if the running user is not english the profile name is different. So if I change my language setting and run the same test I get List has no rows for assignment to SObject because the Name is now 'Administrador del sistema'. So my question is, how can I select the standard System Administrator profile in my test in a way that is language independent? I thought I might be able to use the license key but the key is the same for all standard profile licenses. 


Thanks for any help!

Shashikant SharmaShashikant Sharma

Idealy you should not use hardcoded value like this as you have to create multi lingual app. So either take it from Custom Label or from any Custom Setting, where you can update it is leanguage change.


Create a label with name System_Administrator_ProfileName and value "System Administrator"



Profile p = [SELECT Id,Name FROM Profile WHERE Name = Label.System_Administrator_ProfileName];

 If lang changes use translation workbench and update label as well accordingly.



Makes sense, but System Administrator is a standard salesforce profile. I shouldn't have to create the label since they must already have it. Do you know if the labels already exist and is there a reference somewhere for all the labels salesforce has already created in their backend?


Also I want to point out that some unit test examples given by salesforce use a hard coded profile name


These should be changed to reflect the proper language independent way of selecting profiles.



Shashikant SharmaShashikant Sharma

Could not find how to transalete default label of this profile , must be some where in Transalation Workbench -> Translate option

tried with different options but could not find , I wil try more on this If I will find will update. But I think the suggestion that I gave to you should work for you.


It would but i'm trying to avoid adding a custom label to store the information that's already in the system or packaging a custom profile just for tests. If it's the only option then I'll do it :) 


Thanks for your help!

Did anyone ever figure out a way to get the current value of the system administrator profile name in the context of the current user?  
Also looking to see if anyone figured this out.
Hello guys!

You can use this query for system admin profile:
select id,name from Profile where (UserType = 'Standard' 
            AND PermissionsCustomizeApplication = true) ORDER BY CreatedDate ASC limit 1
This way only system admin profile returns on the query.

If need to get Standard User Profile just change PermissionsCustomizeApplication = false.
Franz Anthony Rodríguez MaravíFranz Anthony Rodríguez Maraví
Hi everybody!
It had been more than two years since the last answer, and actually it guided me to get another query:
Select Name 
From Profile 
Where (UserType = 'Standard' AND PermissionsPrivacyDataAccess = true) 
Order By CreatedDate ASC 
I have tried at a clean org and this is the only permission (PrivacyDataAccess) System Administrator have and other don't. At this point, Ordering y Limit are not totally required, but just in case, they are useful.
Additionaly, I have tried to query profiles only with ordering by CreatedDate, and I got System Administrator too, but it better to use another filter.
Then, you will always get System Administrator profile name, no regard your system language.