> For the complete documentation index, see [llms.txt](https://doc.orbeon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.orbeon.com/form-runner/advanced/buttons-and-processes/actions-form-runner/actions-form-runner-control-setvalue.md).

# control-setvalue action

## Availability

[\[SINCE Orbeon Forms 2025.1.1\]](/release-notes/orbeon-forms-2025.1.1.md)

## Introduction

The `control-setvalue` process action sets the value of a form control.

This process action matches the semantic of the `<fr:control-setvalue>` action in the [action syntax](/form-builder/advanced/services-and-actions/actions-syntax.md#setting-the-value-of-a-control).

## Syntax and parameters

### General syntax

```
control-setvalue(
    control-name = "my-control",
    value        = "my-expression",
    at           = "end",
    section-name = "my-section"
)
```

### Parameters

| Parameter      | Mandatory | Value                                                                    | Comment                                                   |
| -------------- | --------- | ------------------------------------------------------------------------ | --------------------------------------------------------- |
| `control`      | Yes       | control name                                                             | identifies the control to modify                          |
| `value`        | Yes       | value expression                                                         | resolves to the value to set                              |
| `at`           | No        | space-delimited position tokens: `start`, `end`, `all`, positive integer | missing leading tokens default to `end`                   |
| `section-name` | No        | section name                                                             | section name to search, if it contains a section template |

* `value`
  * the value expression is evaluated in the context of the root element of the form data and the resulting value is set on the control
  * you can use the `$foo` syntax to refer to the value of another control, where `foo` is the name of that control in the same scope (i.e. in the same section template instance, or at the top level if not in a section template)
* `section-name`
  * specifies the name of a form section identifying one or more (in case of repeated sections) section template instances included in the form
  * the search is limited to searching within those sections
  * if the section name does not identify a section containing a section template, the function returns the empty sequence

## Examples

Set the value of a top-level form control called `contact-information-first-name` to the value "Homer":

```
control-setvalue(
    control-name = "contact-information-first-name",
    value        = "'Homer'
)
```

Set the value of a top-level repeated form control, on the first repetition:

```
control-setvalue(
    control-name = "top-level-repeated-control-1",
    value        = "'A'",
    at           = "start"
)
```

Set the value of a top-level repeated form control, on the second repetition:

```
control-setvalue(
    control-name = "top-level-repeated-control-1",
    value        = "'B'",
    at           = "2"
)
```

Set the value of a top-level repeated form control, on the last repetition:

```
control-setvalue(
    control-name = "top-level-repeated-control-1",
    value        = "'Z'",
    at           = "end"
)
```

Set the value of all repetitions of a top-level repeated form control:

```
control-setvalue(
    control-name = "top-level-repeated-control-2",
    value        = "'X'",
    at           = "all"
)
```

Set the value of a set of form controls in a section template, by specifying the section name `address-us`:

```
control-setvalue(
    control-name = "us-address-street-1",
    value        = "'742 Evergreen Terrace'",
    section-name = "address-us"
)
then control-setvalue(
    control-name = "us-address-city",
    value        = "'Springfield'",
    section-name = "address-us"
)
then control-setvalue(
    control-name = "us-address-state",
    value        = "'OR'",
    section-name = "address-us"
)
then control-setvalue(
    control-name = "us-address-zip",
    value        = "'99999'",
    section-name = "address-us"
)
```

The above actions can result in the following values in a test form, if combined in the following process for application `my-app` and form `my-form`, in `new` mode, and executed after controls are processed:

```
<property as="xs:string" name="oxf.fr.detail.process.after-controls.foreground.new.my-app.my-form">
         control-setvalue(control-name = "contact-information-first-name", value = "'Homer'")
    then control-setvalue(control-name = "top-level-repeated-control-1",   value = "'A'",                     at = "start")
    then control-setvalue(control-name = "top-level-repeated-control-1",   value = "'B'",                     at = "2")
    then control-setvalue(control-name = "top-level-repeated-control-1",   value = "'Z'",                     at = "end")
    then control-setvalue(control-name = "top-level-repeated-control-2",   value = "'X'",                     at = "all")
    then control-setvalue(control-name = "us-address-street-1",            value = "'742 Evergreen Terrace'", section-name = "address-us")
    then control-setvalue(control-name = "us-address-city",                value = "'Springfield'",           section-name = "address-us")
    then control-setvalue(control-name = "us-address-state",               value = "'OR'",                    section-name = "address-us")
    then control-setvalue(control-name = "us-address-zip",                 value = "'99999'",                 section-name = "address-us")
</property>
```

![Result of setting the value of controls](/files/t7leBliBMz5OPiPdJ2Qd)

Set the value of a top-level form control called `second-control` with the value from a first control called `first-control`:

```
control-setvalue(
    control-name = "second-control",
    value        = "$first-control"
)
```

## Earlier Orbeon Forms versions

With Orbeon Forms 2025.0 and earlier, you have to use the lower-level [`xf:setvalue` action](/form-runner/advanced/buttons-and-processes/actions-xforms.md#xfsetvalue) to set the value of a control. The drawback is this is that you have to directly reach data in the XML document containing all of the form data. The new `control-setvalue` action allows you to set the value of a control without having to know where in the XML document the data for that control is stored.

## See also

* [`fr:control-setvalue` action](/form-builder/advanced/services-and-actions/actions-syntax.md#setting-the-value-of-a-control)
* [`xf:setvalue` action](/form-runner/advanced/buttons-and-processes/actions-xforms.md#xfsetvalue)
* [Form Builder actions syntax](/form-builder/advanced/services-and-actions/actions-syntax.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://doc.orbeon.com/form-runner/advanced/buttons-and-processes/actions-form-runner/actions-form-runner-control-setvalue.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
