You need to sign in to do that
Don't have an account?
Tom H.
Organization.id and necessary CRUD Access for user profiles
Are there profile settings that can make the "Organization" object available to non-admin users?
My application runs fine for admins but blows-up for non-admin users in the following method:
public static id getOrgId() {
return [Select o.Id From Organization o limit 1].get(0).id;
}
The error shown on the page is:
Insufficient Privileges |
You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary. |
Please advise.
Tom
You are right. Unfortunately, setting "view all data" on for every user (in effect, making every user a sys admin) would create some security concerns. The good news is that I did find a solution so I'm posting it here so others will benefit....
System.UserInfo.getOrganizationId()
While I thought it was odd that a method called "getOrganizationId()" is available on a class called "UserInfo", I'm not going to complain. It solved my problem. This code appears to run without failing for both non-system admin and system admin users.
All Answers
The respective user profile has to have "View All Data" privilege (which the System Admin Profile has) in order to access the Organization object.
You are right. Unfortunately, setting "view all data" on for every user (in effect, making every user a sys admin) would create some security concerns. The good news is that I did find a solution so I'm posting it here so others will benefit....
System.UserInfo.getOrganizationId()
While I thought it was odd that a method called "getOrganizationId()" is available on a class called "UserInfo", I'm not going to complain. It solved my problem. This code appears to run without failing for both non-system admin and system admin users.
Perfect. That code would work for all Users. I didn't realize that all you wanted was the Id of the Organization. I had thought that you wanted to query additional Org related information. Thanks for posting your solution for the benefit of the rest of the community....