SettingsService seems to only getting the Global values of a setting

Daniel Main asked on December 23, 2022 22:17

Currently attempting to grab settings but the SettingsService is only getting the global values. even when the "Inherit from global settings" is not checked. For those that are able to be resolved via macros the correct value is retrieved.

Any suggestions? for the ones I am useing the SettingsService I am not able to get the security info as I have yet to figure out how to find it. currently on v13.0.73

Correct Answer

Brenden Kehren answered on December 27, 2022 14:50

There are two ways to get setting values. I'd highly recommend using the first approach all the time:

Gets the value of the "Page not found URL" setting for the current site. It will default to the global setting is no site specific value is found (inherit box is checked at the site level). string pageNotFoundUrl = SettingsKeyInfoProvider.GetValue(SiteContext.CurrentSiteName + ".CMSPageNotFoundUrl");

Gets the global value of the "Page not found URL" setting. It will only ever grab the global value and never return a site specific value. string pageNotFoundUrl = SettingsKeyInfoProvider.GetValue("CMSPageNotFoundUrl");

1 votesVote for this answer Unmark Correct answer

Recent Answers


Juraj Ondrus answered on December 26, 2022 06:58

What is the code you are using and where are you using it? I just tried using the code from API examples and it is working fine.

1 votesVote for this answer Mark as a Correct answer

Daniel Main answered on December 27, 2022 16:12

Thanks Brenden, this really helped, I was using the examples in the online documentation:

var value = settingsService[SettingName];

But as stated it was just providing the Global value. yours did provide the site specific value.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.