ClientsCRIPT OnChange NE FONCTIONNE PAS

Hicham-dev
Tera Contributor
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    // Vérifiez si le champ modifié est 'Estimatih HT'
    if (control == 'u_estimatif') {
        calculateAndSetC();
    }

    function calculateAndSetC() {
        // Récupérer les valeurs des champs 'u_estimatif' et 'u_taux_de_r_ussite'
        var valueA = g_form.getValue('u_estimatif');
        var valueB = g_form.getValue('u_taux_de_r_ussite');

        // Effectuer le calcul
        var result = (parseFloat(valueA) * parseFloat(valueB)) / 100;

        // Définir le résultat dans le champ 'u_estimatif_pond_r'
        g_form.setValue('u_estimatif_pond_r', result);
    }
}
2 ACCEPTED SOLUTIONS

Depending on the field types, you will want to use with "getDecimalValue" (probably) or "getIntValue" to retrieve the value of the fields as numbers and then do your calculation.  The problem is parseFloat is tripping up on the space between "10" and "000" and only returning 10 as the result in your example.  So (50 * 10) / 100 = 5

View solution in original post

The field type should be same for all 3 variable. 

u_estimatif ,u_taux_de_r_ussite,u_estimatif_pond_r

 

add the replace() method and try again. 

 

var valueA = g_form.getValue('u_estimatif').replace(/,/g,'');

 

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

View solution in original post

12 REPLIES 12

The field type should be same for all 3 variable. 

u_estimatif ,u_taux_de_r_ussite,u_estimatif_pond_r

 

add the replace() method and try again. 

 

var valueA = g_form.getValue('u_estimatif').replace(/,/g,'');

 

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

@AshishKM merci pour votre aide maintenant cela fonctionne

Merci d'avoir marqué la solution acceptée et utile, heureux de vous aider et merci spécial à Google Translate.

AshishKMishra_0-1700577269621.png

 

 


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution