AnsweredAssumed Answered

How to get share form value from different fields?

Question asked by sprincess on Mar 17, 2017
Latest reply on Mar 20, 2017 by afaust

Hello,

 

In my share config custom form, I have defined a validation handler on the field by the javascript file custom-form-handler.js

<config>
    <forms>
        <dependencies>
            <js src="/js/custom-form-handler.js"/>
        </dependencies>
    </forms>
</config>

 

<field id="wfm:quantity1" label="Quantity1">
          <constraint-handlers>
             <constraint type="MANDATORY" validation-handler="MyCustomNamespace.checkAmount" event="keyup"/>
           </constraint-handlers>
          </field>

 

custom-form-handler.js:

if (typeof MyCustomNamespace == "undefined" || !MyCustomNamespace) {
    var MyCustomNamespace = {};
}

 

MyCustomNamespace.checkAmount=
    function checkAmount(field, args, event, form, silent, message) {
    var valid = alert(field.value)

    return valid;
}  

I can get the field (wfm:quantity1) by use "field.value" to retrive the form field value.

 

May I know how can I get the other form field value in my custom-form-handler.js?

As I know, the field parameter is referring to what field I defined in the share config custom form.

 

In my case, I want to get the other form field value to do calculation in the custom-form-handler.js,

something like calculation of the form field value of "wfm:quantity1" * "wfm:itemA"

 

May I know how can I achieve this?

In addition, how can I put the value into the other different form field?

something like: DOM.getElementbyId(fieldName).value= "wfm:quantity1" * "wfm:itemA"

 

Thanks for your kindly help, any feedbacks are appreciated.

 

BR,

Mandy

Outcomes