Text + Text

➕ Combine two text fields to create a single field.

1. Overview

This interaction is designed to combine or concatenate two text field values to create a new value.

2. Examples

Refer to the examples below:

2.1. Example 1

In this example, two text fields, first-name and last-name are combined to create a single value fullName.

async function handler(C) {
    let actions = [];

    const fullName = C.concatFieldValues(["first-name", "last-name"], " ");

    actions.push(C.setValue("full-name", fullName));

    return C.mergeAll(actions);
}

2.2. Example 2

This example uses an IF function to see if both first-name and last-name text fields have values, and if so, it combines them to create a full name in the name field. If they don't have any values, it returns an object without modifying the name field.

async function handler(clev) {
    let returnCommands = { values: {}, fieldMeta: {} };
    let firstName = clev.getValue("first-name");
    let lastName = clev.getValue("last-name");
    let name = clev.getValue("name");

    if (firstName.length > 0 && lastName.length > 0) {
        returnCommands.values.name = firstName + " " + lastName;
        return returnCommands;
    }
}

📌 Need Help?

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