You need to sign in to do that
Don't have an account?
Opster
Query a Custom Setting to find Current User's permissions
I have created a custom setting from which I am able to restrict access to editing a text box on certain Visual Force pages. This works great. However I am running into an issue when I want to query against the custom setting to find out the user's permissions via the API.
From my APEX code I am able to do the following to get the Instance value of the custom setting based on the current user's PID
SomeCustomSetting__c.getInstance(pid);
How can I accomplish the same thing using a SOQL query?
Add a WHERE clause to filter by the user's profile id.
Select <fields> from CustomSetting__c where SetupOwnerId = <insert profile Id>
All Answers
You can query custom settings using SOQL in the API.
For example,
Select a.SetupOwnerId, a.Name, a.Id From ListSetting__c a
Two rows returned from your example.
That query is helpful because it returns the PID for one of the result rows, and the other is the org default.
But how can I get back just one row giving me the permissions based on the current users profile?
So the query will be run as the current user and I just want to know do I make this text field editable = TRUE, or FALSE?
I dont want to have to compare the PID's to the Current Users PID if possible.
thanks
Add a WHERE clause to filter by the user's profile id.
Select <fields> from CustomSetting__c where SetupOwnerId = <insert profile Id>