> For the complete documentation index, see [llms.txt](https://brixxbox.gitbook.io/brixxbox-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://brixxbox.gitbook.io/brixxbox-documentation/client-api-reference/functions/setfieldvalue.md).

# setFieldValue

brixxApi function to set a value to a field

### Parameters

1. controlId => Id of the control
2. value => The value, you want to set. This could be a number, a date, a string (depending on the control type of course). setFieldValue will do all the conversions for you.

### Example Usages

1\. Simple textbox

```javascript
   brixxApi.setFieldValue("myControlId", "Hello World!");
```

2\. With a variable

```javascript
   let myText = "Hello World!";
   brixxApi.setFieldValue("myControlId", myText);
```

3\. Setting a date

```javascript
   brixxApi.setFieldValue("myDateControl", "2019-01-31"); //This is the format, you would get by getFieldValue
   brixxApi.setFieldValue("myDateControl", new Date()); //This will set todays date.
   brixxApi.setFieldValue("myDateControl", new moment().add(1, "month")); // you can use moment to set calculated dates. See https://momentjs.com/ for more details and examples
```

4\. Setting a date to a calendar control scrolls to that date.

```javascript
   brixxApi.setFieldValue("myCalendarControl", "2019-01-31");
```

5\. The Calendar supports subcontrols to set. You can add resource(s) to the calendar for example:

```javascript
   //resources will delete all and set a new array of resources
   brixxApi.setFieldValue("myCalendarControl.resources", [ 
   {
       id: 1,
       title: "Room A",
   },
   {
       id: 1,
       title: "Room B",
   }]);

   //resource will add a single resource
   brixxApi.setFieldValue("myCalendarControl.resource", { 
       id: 1,
       title: "Room A",
   });
```

### Demo

{% embed url="<https://youtu.be/MRnw31QAt0M>" %}
