Set End Time on Change of Duration

šŸ Update end times dynamically.

1. Overview

This interaction is designed to update the End Date field based on changes made to the Duration field.

2. Example

This interaction triggers when changes are made to the Duration field.

  1. It retrieves the values of the Start Date and Duration fields using a getValue() function.
  2. If both the Start Date and Duration values are available, it pushes an action to set the End Date field with the calculated End Date (in "YYYY-MM-DD" format) using a setValue() function.
startDate = May 2, 2023
duration = 1 days
endDate = May 3, 2023


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

    let startDate = C.getValue("1662670-start-date");
    let duration = C.getValue("1662670-duration");

    let endDate = C.moment(startDate)
        .add(duration, "days")
        .format("YYYY-MM-DD");

    if (startDate && duration) {
        actions.push(C.setValue("1662670-end-date", endDate));
    }

    return C.mergeAll(actions);
}

šŸ“Œ Need Help?

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