Select + Select

🧷 Combine two selected fields efficiently.

1. Overview

This interaction involves combining two select fields and combining them to form a single new field.

2. Example

In the example below, the function combines the selected values from the shift and worker fields, concatenates them with a hyphen, and sets the result as the new value for the name field.

async function handler(clev) {
    let actions = [];
    let shift = clev.getValue("shift");
    let worker = clev.getValue("worker");

    let shiftSelect = clev.getValue("shift");
    let shiftObject = await clev.api.getEntry({
        recordId: "248707",
        responseType: "iov",
        id: shiftSelect,
    });
    let shiftName = shiftObject["name"];

    let workerSelect = clev.getValue("worker");
    let workerObject = await clev.api.getEntry({
        recordId: "199",
        responseType: "iov",
        id: workerSelect,
    });
    let workerName = workerObject["name"];

    let name = clev.getValue("name");

    const setName = shiftName + " - " + workerName;

    if (shift.length > 0 && worker.length > 0) {
        actions.push(clev.setValue("name", setName));
    } 

    return clev.mergeAll(actions);
}

šŸ“Œ Need Help?

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