Find your content:

Search form

You are here

Custom Settings creation through Apex without SetupOwnerId property

 
Share

Is it important to specify SetupOwnerId in order to insert only defaults in managed package settings.SetupOwnerId = UserInfo.GetOrganizationId();

Is the custom settings created for current user or for org if I don't specify SetupOwnerId on insert? like in the example:

Settings__c settings = Settings__c.getOrgDefaults();
if (settings.id == null) {
    insert alertSettings;    
}

Attribution to: Natallia

Possible Suggestion/Solution #1

Its not important to specify it as the SetupOwnerId will be set to the Organization Id if you do not specify it.

I assume your code should of been this (settings rather than alertSettings):

Settings__c settings = Settings__c.getOrgDefaults();
if (settings.id == null) {
    insert settings;    
}

Attribution to: BarCotter
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/33464

My Block Status

My Block Content