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

Create or Update Custom Setting Values for User Id or Profile Id via Apex
Does anyone know if it is possible using Apex to create or update a custom setting value specifically for a user Id or profile Id? The Salesforce documentation does not touch this functionality, so I don't know if it is even supported.
Thanks!
Right, here goes -
The SetupOwnerId field on a Hierarhical Custom Setting indicates which User / Profile this setting applies to
For a Custom Setting Test, which I want to create for a User u
All Answers
Heres a link to a post by the inimitable Jeff Douglas, explaining how
http://blog.jeffdouglas.com/2010/02/08/using-hierarchy-custom-settings-in-salesforce-com/
This does not answer my question. I did find this in my search before posting this question. My question is regarding APEX creation or updates to an existing heirarcical custom setting field for a specific user id or profile id. I can successfully create and update a heirarcical custom setting field for the organization, but cannot figure out how to do this for a user or profile.
The cool thing is now you can programmatically access these custom settings based upon the running user and return their most appropriate value (org-wide, profile or user) in formula fields, validation rules, Apex and the Force.com Web Services API with the following interface. Be sure to check out the custom settings docs for more detailed usage.
That's an extract from the article, if you scroll further down. It does talk about accessing value for profiles and users rather than org wide, also has screenshots!
I understand how to access the values. How can I CREATE a setting for a specific user or profile? From what I can tell, nothing in this article references that.
Right, here goes -
The SetupOwnerId field on a Hierarhical Custom Setting indicates which User / Profile this setting applies to
For a Custom Setting Test, which I want to create for a User u
Perfect! Thank you! Perhaps I just missed that on the page... Maybe it could be made clearer in the Salesforce documentation?
I double checked, and SetupOwnerId is not mentioned on Jeff Douglass's page nor the Salesforce documentation. Did you just happen to know this or did you find it somewhere?
yeah its not on the page. i had a hunch, looked up the object fields in the schema explorer in the force.com ide, created a couple of custom setting rows, and worked my way backwards :)
Remember, custom settings are nothing but custom object expect when it comes to caching. So you can use explorer to get field API names and also use DML similar to custom object.