GetSections() and GetKeys() exposed in the SoPreference class.
Code
The following example shows how we can change the calendar start date (Sunday or Monday) for a given user.Walk-through
Here we use theSetPreference method of the SoPreference class. The method provides four overloads depending on the input value, which could be either a string, int, DateTime, or bool value.
The first two parameters (preference section and the corresponding preference key) are always set and they are both of string types. Here, the last parameter is the new value used.
Once the code is executed the results can be seen through the application:
The relevant section from the code that made the above change is:
GetSections
When setting preferences, we may need to know what sections are already found in the database. To get the available sections, we may callGetSections(). The method will return an array of all sections defined for the current associate from the cache if possible or from the database. However, it is possible to add your own preference sections to the application.
GetKeys
Once we have figured out which section to use, the next is to get the specific key, which relates to the part that we are planning to change. For this, we use theGetKeys method. The method gets all available keys within a section from the cache or the database.