Can I set value in DFFS directly from a function?

Home Forums Classic DFFS Can I set value in DFFS directly from a function?

Viewing 2 reply threads
  • Author
    Posts
    • #16802
      Bryan Waldrop
      Participant

        I am attempting to set a multi choice field based on another multi choice fields selection in NewForm

        function NewFUNC(){
        var MMF=getfieldvalue(‘MyMultiField1’);
        var MMFTRU=MMF.includes(‘Value2’);
        if(MMFTRU ==true){
        setfieldvalue(‘MyMultiField2′,’Value2′);
        }
        else{
        setfieldvalue(‘MyMultiField2’,’Value1’);
        }

        }

        How should I go about this?

      • #16820
        Alexander Bautz
        Keymaster

          Hi,
          Please note that the “includes” method doesn’t work in IE.

          I suggest you do it like this:

          var fArr = getFieldValue("MultiChoiceField1");
          if(jQuery.inArray("Value2",fArr) > -1){
              setFieldValue("MulitChoiceField2","Value2");
          }else{
              setFieldValue("MulitChoiceField2","Value1");
          }

          Please note that the setFieldValue will clear existing selection before the new value is set. If this is not what you want you’ll have to pull the array from “MulitChoiceField2” and push the new value in before setting the complete array of values.

          Hope this makes sense,
          Alexander

        • #16846
          Bryan Waldrop
          Participant

            perfect thank you!

        Viewing 2 reply threads
        • You must be logged in to reply to this topic.