Set field value based on another field value (with javascript)

评论

1 条评论

  • Avatar
    Varun Agasthya

    Hi Ciprian,

    My analysis of your code revealed a syntactical error where you missed wrapping the eFormHelper methods in a separate function.

    function calculateAndSetAmountField() {

    var options = {};
    options.fieldId = 'Diferentadezilenplus1cheltronnnx';

    eFormHelper.getFieldValue(options, function (result) {
      if (result.isSuccess) {
        var fieldValue = parseFloat(result.data);
        var amount = calculateAmount(fieldValue);

        options.fieldId = 'ValDiurnacalculataautomatcheltronx';
        options.value = amount.toString();

        eFormHelper.setFieldValue(options, function (result) {
          if (result.isSuccess) {
            console.log("Amount calculated and set successfully.");
          } else {
            console.log(result.error);
          }
        });
      } else {
        console.log(result.error);
      }
    });

    }

    Please ensure that the function wrapped for the eFormHelper methods (i.e. calculateAndSetAmountField()) is attached to the click event of the button in order to achieve the desired functionality.

    0
    评论操作 固定链接

请先登录再写评论。