Making catalog task variable mandatory in the sctask form based on sc_task state and another variabl

JPSS
Tera Contributor

Could you please help me to make a variable mandatory in the sc_task form based on sc_task state and another varaible

Please help....

5 REPLIES 5

Community Alums
Not applicable

Try this template for a catalog client script on change

 

function onChange(control, oldValue, newValue, isLoading) {

    if (isLoading || newValue === '') {

        return;

    }

 

    // Get values of the dependent variable and state

    var dependentVariable = g_form.getValue('u_dependent_variable'); // Replace with your dependent variable's name

    var state = g_form.getValue('state'); // Replace 'state' with the relevant field, if exposed

 

    // Condition to make the target variable mandatory

    if (state === '3' && dependentVariable === 'specific_value') { // Replace with actual values

        g_form.setMandatory('u_target_variable', true); // Replace with your variable's name

    } else {

        g_form.setMandatory('u_target_variable', false); // Optional otherwise

    }

}