📍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 datebased on the selected terms. - On change of terms: Automatically updates the
due datebased 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.
- It starts by obtaining the value of the
centrefield usinggetValue()function. - It extracts the information from the fetched data and performs the following actions:
- Sets the value of
centre-addresswith adescriptionfield containing the centre's address. - Sets the value of
centre-phoneto the centre's phone number or an empty string if the phone number is not available.
- Sets the value of
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?
