You need to sign in to do that
Don't have an account?

Custom Settings to hold User Preferences Permission Issue
i was hoping to use a hierarchical custom settings object to store user preferences for an app. This would require the user to create and edit their custom setting record.
From what i have read this would require every user to have the "Customize Application" permission to create and edit their own custom setting record. Obviously we cannot do that.
Is there some way to get around this with a vfpage & apex? So the user can goto a vfpage and create/edit the custom settings object record so they can manage their preferences?
So I just did a basic test and it appears there may be an issue with binding directly to the setting object. If you bind your form inputs against properties or an apex object that addressed the issue for me, i.e. this threw an error on save for a non-admin user:
but this did not:
I'm checking with the team to see if this is a bug. I'll update this thread with the answer.
Let me know if that workaround addresses your issue.
Regards,
Andrew
All Answers
Yes, you can expose a settings management page built in Visualforce, backed by an Apex controller which will allow the user to manage their settings. This works because Apex runs in system mode. You control access to execute Apex at the entry points - class-level security for webservice methods and page-level security for Visualforce page invocations. Within Apex you can detect the running user's permissions and choose how you would like to behave accordingly.
Hope that helps. Post back here if you need more assistance.
Regards,
thanks mt. we've done that and it still will not create or edit the custom settings record unless with give the Customize Application permission on their profile. Is there something we need to do specifically to the controller?
There shouldn't be anything to do beyond what it seems you've done. What user type can't update the setting info through Apex and what error are you getting?
So I just did a basic test and it appears there may be an issue with binding directly to the setting object. If you bind your form inputs against properties or an apex object that addressed the issue for me, i.e. this threw an error on save for a non-admin user:
but this did not:
I'm checking with the team to see if this is a bug. I'll update this thread with the answer.
Let me know if that workaround addresses your issue.
Regards,
Andrew
thats funny we just figured that out ourselves and came back to post about it.
Crazy little bug took me forever to figure it out. The weird thing was it never even threw any error, even in a try catch. It would through show the debu log as /apex/apex/test2 instead of /apex/test2 but with no errors. very odd.
thanks for the help!
Nice :)
Still discussing what the bug is here. Clearly the current behavior is not correct.
More to come.
Thanks for your patience and glad you are moving forward again.
Regards,
Any upadates on this?
I tried the first sample code specified in the mtclimber post. and got following error.
First I got Name not specified and then following one
Link to Screenshot: https://doc-0c-14-docs.googleusercontent.com/docs/secure/j3ltqks70m9majlvhsb4ldn8uob48dal/0q5mfhqnghn3e3uf6vpqclicmju5vhqb/1282543200000/11496381913340529911/11496381913340529911/0B4kSZwssd_g8MWYxOWNlNDEtY2JmMy00OTgxLWI4M2UtMTM0MDcwNmJlNmEy?nonce=84qk8svfqcg9o&user=11496381913340529911&hash=92j7033kkr2d9qq099npsd4gu0h19gdb
Thanks for this code!
Do you know how to get the label for a custom setting field in apex?
Tried variations on CustomSetting__c.Field1__c.Label to no avail.
I know this is an old thread, but these are where I learn Apex and VF. Was there ever a resolution to this? Thanks