• jwilkinson
  • 0 Points
  • Member since 2012

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 1

We've done some testing with the hierarchical custom settings feature and have run into what appears to be limitation when managing individual user settings from Apex (hopefully not).


We created a custom setting object and simple checkbox field (let's call it UI_Settings__c.Show_Feature__c) and would like our apex code to be able to store individual user settings for that value.  Something like this:



public PageReference saveUISettings() { UI_Settings__c userInstance = UI_Settings__c.getValues(UserInfo.getUserId()); userInstance.Show_Feature__c = this.showFeature; update userInstance; // save changes to UI preferences.

return null; }


 This works fine if we have manually configured a custom setting instance for each user through the Salesforce UI.  But it looks like we can't store user-level settings if the custom setting instance hasn't been created for a user.  And there appears to be no way to create that custom setting instance from Apex.


Is this true?