setFieldValue

app 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

app.setFieldValue("myControlId", "Hello World!");

2. With a variable

let myText = "Hello World!";
app.setFieldValue("myControlId", myText);

3. Setting a date

app.setFieldValue("myDateControl", "2019-01-31"); //This is the format, you would get by getFieldValue
app.setFieldValue("myDateControl", new Date()); //This will set todays date.
app.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.

app.setFieldValue("myCalendarControl", "2019-01-31");

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

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

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

Demo

Return Values

The function handles various types of controls and returns the updated field value after performing the necessary operations. If the control doesn't exist, it returns null. See demo.

Last updated