When designing software for both small-sized and medium-sized businesses, there is often a balancing act in the designing setup options. Where some companies only require a feature to be turned on or off, other businesses require them to be more flexible.
The Multi-Level Setup pattern is explained at https://www.youtube.com/watch?v=kMtzKFjU22U&list=PLhZ3P-LY7CqmVszuvtJLujFyHpsVN0U_w&index=30.
In order to allow the best of both worlds, we can simply add the setup options to both the tables, and write a small interface to read the values based on importance.
The setup fields need to be implemented on at least two levels, for example, a Singleton and Supplemental table. The setup options should be identical.
To read the setup values, we need to provide a function that first checks the most detailed level, the Supplemental table, and then the Singleton table.
The following code snippet is a part of Codeunit 11 Gen. Jnl.-Check Line, and checks the values of Allow Posting From and Allow Posting To in reference to a PostingDate variable:
DateNotAllowed(PostingDate : Date) : Boolean IF (AllowPostingFrom = 0D) AND (AllowPostingTo = 0D) THEN BEGIN IF USERID <> '' THEN IF UserSetup.GET(USERID) THEN BEGIN AllowPostingFrom := UserSetup."Allow Posting From"; AllowPostingTo := UserSetup."Allow Posting To"; END; IF (AllowPostingFrom = 0D) AND (AllowPostingTo = 0D) THEN BEGIN GLSetup.GET; AllowPostingFrom := GLSetup."Allow Posting From"; AllowPostingTo := GLSetup."Allow Posting To"; END; IF AllowPostingTo = 0D THEN AllowPostingTo := 31129999D; END; EXIT((PostingDate < AllowPostingFrom) OR (PostingDate > AllowPostingTo));