Bug reports Found a bug? Post it here please.
Version 7.x > Bug reports > Custom Settings Values View modes: 
User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 7/11/2013 12:44:52 PM
   
Custom Settings Values
I use the custom settings to store connection strings to other minor satelite databases, URLs to some external services and other things that could be stored in the web.config appSettings section but change in our different environments. I'm finding now that the values displayed in the UI, what is stored in the database and what is retrieved via the API are all different/incorrect.

For instance I have a URL to a service I use for credit checking/reporting. I entered the new Key in our dev server I used a code name of AppUrl, selected my group (which is the same as my site code name), set the type to string and entered a default value of https://test.creditcheckersolutions.com/. I then went and synced that key over using Content Staging. When I went to the live site, I saw exactly as I had entered. So I changed the default value in the UI to https://live.creditchecksolutions.com/ expecting that when I used
SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".AppUrl");
I would get back https://live.creditchecksolutions.com/. I was mistaken, I'm receiving the initial value (KeyValue) that was entered and not the value I updated in the UI (KeyDefaultValue).

When I look in the database I see there are 2 fields in the CMS_SettingsKey table, KeyValue and KeyDefaultValue. It appears on creation of the Key both the KeyValue and KeyDefaultValue are set to what is entered in the Default value field. When I went to live and updated the default value only the KeyDefaultValue was updated and the KeyValue field (which is returned by the method above) had the incorrect value in it.

Is this by design? I hope not. I'm using v7.0.40 and didn't see anything in Bugtracker stating this was resolved or reported in any newer hotfixes.

User avatar
Member
Member
kentico_sandroj - 7/14/2013 8:53:49 PM
   
RE:Custom Settings Values
Hello,

I used the following to get the default value:

SettingsKeyInfo CustomKey = SettingsKeyProvider.GetSettingsKeyInfo("test");
if (CustomKey != null)
{
Label1.Text = CustomKey.KeyDefaultValue;
}


I am not sure if this is the best approach so somebody might have a better suggestion once they get into the office tomorrow. You also have the option of using KeyValue to store the setting instead of KeyDefaultValue then you can use the method you mentioned. I am not able to comment on whether this is by design or not - perhaps somebody from the Czech office can ask the developers that designed it.

Regards,
Sandro

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 7/14/2013 9:45:48 PM
   
RE:Custom Settings Values
Thank you Sandro for the info. I don't have a problem using a different method to get the key (although documentation suggests the one I referenced). The problem is within the UI you only have the option to set the default value and not the actual KeyValue I'd receive from using your suggested method or mine.

User avatar
Member
Member
kentico_sandroj - 7/14/2013 10:53:45 PM
   
RE:Custom Settings Values
No problem, you're very welcome. You can set the actual value in Site Manager > Settings > Custom settings - Please let me know if that option is not available for you.

Regards,
Sandro

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 7/14/2013 11:13:55 PM
   
RE:Custom Settings Values
Man I feel like an idiot! I see where it is now and what it's used for. I've always seen it in there but never clicked on it. Thanks for setting me straight Sandro.

User avatar
Member
Member
kentico_sandroj - 7/15/2013 3:33:27 PM
   
RE:Custom Settings Values
No worries, I am glad I could help on the rare occasion that you ask for it :)

Regards,
Sandro