Skip to content

Add or update a preference value

This operation upserts a single preference key/value pair into the in-memory Preference set. The change is not persisted until Persist preferences runs.

Field Value
Operation ID OP-PRES-003
Trigger Consuming code calls Add(inKey, inValue) or Add(inKey, inValue, inScope)
Inputs Key, value, optional PrefScope (defaults to PageLevel)
Outputs Mutated in-memory Preference record
Primary components clsPreferences.Add (two overloads)
Entry point SAIF.Presentation/clsPreferences.vb

Steps

  1. Return silently if the key is Nothing (BR-PRES-006).
  2. Lower-case the key (BR-PRES-007).
  3. Locate the Preference record for the current application + resolved page key.
  4. If none exists: create a new Preference, set its ApplicationName and Pagename, and append it to the list (BR-PRES-013).
  5. If the key already exists in PreferenceItems, remove it first, then add the new value as inValue.ToString() (BR-PRES-014, BR-PRES-015).

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start([Add key, value, scope]) --> D1{Key is Nothing?}
    D1 -->|Yes| EndNoop([Return, no-op])
    D1 -->|No| S1[Lower-case key]
    S1 --> S2[Locate matching Preference record]
    S2 --> D2{Record exists?}
    D2 -->|No| S3[Create new Preference record and append]
    D2 -->|Yes| S4[Use existing record]
    S3 --> S5
    S4 --> S5[Key already present?]
    S5 -->|Yes| S6[Remove existing item]
    S5 -->|No| S7[Add new item]
    S6 --> S7
    S7 --> EndOk([In-memory record updated])

Failure and edge-case behavior

Sources

  • SAIF.Presentation/clsPreferences.vb