Set Rate from Item

💸 Automatically set rates based on selected items.

1. Overview

This Interaction updates the Rate field based on a selected Item. Additionally, it sources and sets a numerical value from the parent field when applicable.

2. Example

In this example, when the Item field is updated, the interaction retrieves information from the selected item and sets the Rate field accordingly.

async function handler(clev) {
    let actions = [];
		
		let itemSelect = clev.getValue("item");
    let itemObject = await clev.api.getEntry({
        recordId: "661820",
        responseType: "iov",
        id: itemSelect,
    });

    let itemRate = +itemObject["rate"]; //"+" converts a string to a number

    if (itemSelect.length > 0) {
        actions.push(clev.setValue("rate", itemRate));
    }

		return clev.mergeAll(actions);
}

📌 Need Help?

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