IF Inside an IF

🎉 Define multiple conditions in one Interaction.

1. Overview

This Interaction allows for the execution of an additional IF condition when the parent IF condition is satisfied. It behaves like a nested IF condition.

2. Example

This interaction example illustrates the use of IF inside an IF. The function below checks the logType to see if it's either 'Time travelled FROM Client' or 'Time travelled TO Client', then it checks the quantity, and if it's over 0.5, it sets the quantity to be 0.5.

async function handler(C){
    let actions = [];
    
    //if log-type is 'Time from Client' or 'Time to Client' -> set quantity to 0.5
    let logType = C.getValue('log-type');
    console.log('logtType: ' + logType)
    if (logType[0] === '705013' || logType[0] === '705014') { // || = OR
        let quantity = C.getValue('quantity');
        console.log('quantity: '+quantity)
        if (quantity > 0.5) {
            actions.push(C.setValue('quantity', 0.5));
        }
    }
    
    return C.mergeAll(actions);
}

📌 Need Help?

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