Output the value of an enumeration along with other text

Hi,

I have an enum (dropdown) field in my form (which uses external enumeration, but i think it doesn’t matter here), in which a user can be selected:

At another place in the form, I want to just display the chosen value from the enum + some additional text, e.g. The user <CHOSEN_VALUE_FROM_ENUM> declares that ...

How can I achieve that? I tried using expressions in the form, but if I add an expression to my form and set the expression to be [fieldName], the UI designer won’t let me save it and says the reference is incorrect.

I’m sure someone else will be able to give a more detailed answer. Depending on where you use the expression in the model relative to the field that you are referencing, you will need to use kontext to navigate through groups to the field (see the “Group Scope” and “Nested Group Scope” entries here )

This is correct.
The [fieldName] reference is usually only valid when used within an expression column of a repeat.
There, the data context is the repeatable group that the repeat itself is bound to.
If fieldName is a field directly in that group, the reference is valid.

When using expression cells (as expression output in a control grid), the data context is dependent on whether or not the control grid is nested in one or more detached repeats.
If it is not nested, the data context is the document model root.
If it is nested, the data context is the repeatable group of the closest detached repeat ancestor.

That means for expression cells you usually have to first navigate to the respective group using the kontext() expressions as lwobig said.

Thank you @lea-noble-kernel @erik-radiant-gorge .
Using

kontext(root) { [fieldName] }

lets the UI designer accept the expression, as my fieldName is within the group root in my model.

Now, how can I add additional text to my expression?
What I would want is to embed this kontext(root) { [fieldName] } into a string.

Add the text within quotes excluding any fields. Using your inital example you would use

"The user " kontext(root){[fieldName]} " declares that"

This should result in a string like:

The user <value in fieldName> declares that