Set Address Value

📍Assign address value based on the terms selected.

1. Overview

This Interaction is designed to customise the behaviour of specific fields within a record. It disables certain fields and is triggered by various events, mainly when fields are updated.

The specific behaviour is as follows:

  • On change of date: Automatically updates the due date based on the selected terms.
  • On change of terms: Automatically updates the due date based on the selected terms.

2. Example

This example shows how the Interaction modifies the behaviour of specific fields by updating their values based on user actions and external data.

  1. It starts by obtaining the value of the centre field using getValue() function.
  2. It extracts the information from the fetched data and performs the following actions:
    1. Sets the value of centre-address with a description field containing the centre's address.
    2. Sets the value of centre-phone to the centre's phone number or an empty string if the phone number is not available.
async function handler(clev) {
    let actions = [];

    let centreSelect = clev.getValue("centre");
    let centreObject = await clev.api.getEntry({
        recordId: "1197776",
        responseType: "iov",
        id: centreSelect,
    });

    let centreAddress = centreObject.address;
    let centrePhone = +centreObject.phone;

    if (centreSelect.length > 0) {
        actions.push(
            clev.setValue("centre-address", { description: centreAddress })
        );
        actions.push(clev.setValue("centre-phone", centrePhone || ""));
    }

    return clev.mergeAll(actions);
}

📌 Need Help?

If you require assistance or encounter any issues, please don't hesitate to contact us for further support.