Base solution for your next web application
Open Closed

Working with Settings in Abp #2841


User avatar
0
bilalhaidar created

Hi, When creating a new SettingDefinition, there is the option to scope it to either 3 options:

User Tenant Application

There is also the option to specify more than one option, for instance a setting applies to User | Tenant.

What does it mean in terms of editing the data?

If I provide an UI to allow admin to edit a SettingDefinition on the Web App. For instance, a SettingDefinition that is scoped to Tenant only. Then, each admin would be changing the value that belongs to his/her own tenant?

If a SettingDefinition is scoped to App and Tenant. When a Tenant Admin changes the value, will that affect also the App version of that Setting?

I am a big confused on how to use the Settings.

I appreciate your assistance.

Thanks


5 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Settings works basically in a hierarcy.

    Application -> Tenant -> User.

    So when you request a setting let's say for a user, setting system checks if there is a value defined for that setting for requested user and returns it, if it is not defined for that user, it get's tenat's setting, if tenant also does not have setting value then App's setting value is returned.

    So,

    If I provide an UI to allow admin to edit a SettingDefinition on the Web App. For instance, a SettingDefinition that is scoped to Tenant only. Then, each admin would be changing the value that belongs to his/her own tenant?

    Yes.

    If a SettingDefinition is scoped to App and Tenant. When a Tenant Admin changes the value, will that affect also the App version of that Setting?

    No, tenant's can only change tenant's settings.

    Of course, you need to use appropriate methods for changing settings, see <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Setting-Management#DocChangeSettings">https://aspnetboilerplate.com/Pages/Doc ... geSettings</a>.

    Please let us know if there are unclear points.

    Thanks.

  • User Avatar
    0
    bilalhaidar created

    Great! So in summary, can I say the following:

    1- A setting X can be scoped to either App, Tenant or User. This is based on how the setting was defined originally. Scoping a setting means, it is available on those scopes to read/edit, correct? So if a setting is defined for App & User, this setting won't have a value for Tenant, only for App and user?

    2- When retrieving a setting value using the generic method of GetSettingValue/Async, it retrieves the value based on the hierarchy. What's the relation between retrieving the value and the scope of the setting definition? How are they linked togther?

    3- When setting the value of setting, I have to decide which method to use, whether to set value on App, Tenant or user level. Also, what's relation between scope of setting definition and setting the value?

    Finally, can we say that the scopes defined on a setting definition also defines the hierarchy used to retrieve the value of the setting? so if Scope is App and Tenant. Then only 2 levels will be searched, otherwise, default value?

    Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I think you are confused with setting scopes, this is the explanation of it <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Setting-Management#DocSettingScopes">https://aspnetboilerplate.com/Pages/Doc ... tingScopes</a>.

    Have you seen it before ?

    Thanks.

  • User Avatar
    0
    bilalhaidar created

    Hello Ismail, Yes I've read this article before. True I am confused about Settings, but I guess I have now a better understanding.

    • Setting Definitions have a scope: Application, Tenant or User
    • If a SD has a scope of A/T means that it could have a value for each and every Tenant and also could have a value on the App level, correct?
    • Setting the values is governed by specific methods. Therefore, I should know ahead of time if I am editing a Tenant SD or Application SD or Usre SD, correct?

    When reading a SD, it is based on the hierarchy. So if I define a SD on App/Tenant levels, if the user is within a Tenant, then if the SD has a value for this Tenant, then it will be retrieved otherwise it will take the App level value otherwise, the default value. Correct?

    Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    • If a SD has a scope of A/T means that it could have a value for each and every Tenant and also could have a value on the App level, correct?
    • Setting the values is governed by specific methods. Therefore, I should know ahead of time if I am editing a Tenant SD or Application SD or Usre SD, correct?

    When reading a SD, it is based on the hierarchy. So if I define a SD on App/Tenant levels, if the user is within a Tenant, then if the SD has a value for this Tenant, then it will be retrieved otherwise it will take the App level value otherwise, the default value. Correct?

    All of them are correct :)