Skip to content

Editor defaultvalue from json property in session or local storage#2224

Open
MattiasSp wants to merge 3 commits intoorigo-map:masterfrom
haninge-geodata:editor-defaultvalue-from-json-property-in-session-or-local-storage
Open

Editor defaultvalue from json property in session or local storage#2224
MattiasSp wants to merge 3 commits intoorigo-map:masterfrom
haninge-geodata:editor-defaultvalue-from-json-property-in-session-or-local-storage

Conversation

@MattiasSp
Copy link
Contributor

Fixes #2218.

Adds the possibility to extract a subvalue from a returned JSON object when getting editor default values from sessionStorage or localStorage.

Now, by specifying the parameter "keyType": "json_path" and using simple dot-notation in the key parameter, values can be extracted from anywhere within the response, provided it can be parsed as JSON. It also works with array indices (e g sessionStorageVariable[2].object.array[0].value).

Config example:

"attributes": [
  {
    "name": "skapad_av",
    "title": "Skapad av: ",
    "type": "hidden",
    "defaultValue": {
      "type": "sessionStorage",
      "keyType": "json_path",
      "key": "oidc_user.displayname",
      "updateOnEdit": false
    }
  }
]

@tonnyandersson tonnyandersson added the Awaiting documentation Docs needs to be provided before approval label Sep 9, 2025
@steff-o steff-o self-requested a review November 3, 2025 14:27
Copy link
Contributor

@steff-o steff-o left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

If the json path is not a leaf, it will get "[Object object]" as default. All other errors will just be empty string. Probably not an issue as it is only the result of bad configuration.

@steff-o steff-o added the PR approved To highlight approved PR:s as it is not shown in list which are approved. label Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Awaiting documentation Docs needs to be provided before approval PR approved To highlight approved PR:s as it is not shown in list which are approved.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use child object from sessionStorage JSON as defaultValue in Editor

3 participants