Basic Examples

Here are some basic example of Interactions that will be the building blocks on creating the user experience needed. Combine a range of these different basic examples to achieve the desired outcome you're looking for.

Setting Field Values

In a lot of cases you're going to want to set some values of some fields. Here's a basic script that will set some values

async function handler(C) {
 	let actions = [];
  actions.push(C.setValue("text-field", "Hello World" )); // Text Field
  actions.push(C.setValue("number-field", 5 )); // Number Field
  actions.push(C.setValue("number-field", 5.01 )); // Number Field can accept decimals
  actions.push(C.setValue("date-field", "2025-01-01" )); // Date Field always in YYYY-MM-DD format
  actions.push(C.setValue("select-field", [1234] )); // Select/Radio Field
  actions.push(C.setValue("checkbox-field", true )); // Checkbox true or false
  actions.push(C.setValue("time-field", '9:00')); // Time Field
	actions.push(C.setValue("phone-field", '0411 111 111')); // Phone Field
  
  
  return C.mergeAll(actions);
  
}

Get the Value of a Field

If you want to know the value of a field, you can simply use getValue.

async function handler(C) {
  let textValue = C.getValue("text-field");
	console.log(textValue); // Will return the value of the text field
  
  return C.mergeAll(actions);
  
}

Filter a Select List

There will be times you want to filter down some options to only give valid options to the end user. We use setFilters for this

async function handler(C) {
  let actions = [];
  actions.push(C.setFilters("assigned-to", [
    {
    	subject: "inactive",
			requestType: "i",
      type: "checkbox",
			operator: "is_false"
    }
  ])
  );
  
  // Will filter the assigned-to field to only display "active" employees
  
  return C.mergeAll(actions); 
  
}

Disable a Field

This will show how to disable a field.

async function handler(C) {
  let actions = [];
  actions.push(C.setFieldDisabled("field-id", true)); // Will disable the field
  actions.push(C.toggleFieldDisabled("field-id")); // Will either disable or enable the field based on it's current state
  
  return C.mergeAll(actions); 
  
}

Make a Field Mandatory

This will show how to make a field mandatory.

async function handler(C) {
  let actions = [];
  actions.push(C.setFieldMandatory("field-id", true)); // Will make the field mandatory
  actions.push(C.toggleFieldMandatory("field-id")); // Will either make field mandatory or not based on it's current state
  
  return C.mergeAll(actions); 
  
}

Hide/Show Field

This will show how to hide a field.

async function handler(C) {
  let actions = [];
  actions.push(C.setFieldHidden("field-id", true)); // Will hide the field
  actions.push(C.toggleFieldHidden("field-id")); // Will either hide or show the field based on it's current state
  actions.push(C.showField("field-id")); // Will show the field
  
  return C.mergeAll(actions); 
  
}