# setFieldValue

### 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>" %}


---

# Agent Instructions: 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:

```
GET https://brixxbox.gitbook.io/brixxbox-documentation/client-api-reference/functions/setfieldvalue.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
