Use multiline text as trigger in DFFS

Forums Dynamic Forms for SharePoint Use multiline text as trigger in DFFS

Viewing 4 reply threads
  • Author
    Posts
    • #12137
      Alexander Bautz
      Keymaster

      Currently you cannot use a multiline text field as a trigger directly, but there is a workaround.

      Add a rule with the trigger “No trigger (must be triggered manually)”, and add this code to the Custom JS textarea:

      // Plain text fields
      $("#dffs_NameOfYourMultilineField textarea").on("change",function(){
          spjs.dffs.triggerRule(["NameOfYourRule"]);
      });
      
      // Enhanced Rich text fields
      var initialRteVal = getFieldValue("NameOfYourMultilineField").replace(/<[^>]*>/g,"");
      $("#dffs_NameOfYourMultilineField div.ms-rtestate-write").on("blur",function(){
          var currVal = getFieldValue("NameOfYourMultilineField").replace(/<[^>]*>/g,"");
          if(currVal !== initialRteVal){
              spjs.dffs.triggerRule(["NameOfYourRule"]);
          }
      });

      Replace “NameOfYourMultilineField” with the name of your field, and “NameOfYourRule” with the “Rule friendly name” of your rule.

      Alexander

    • #15957
      Eric Dickerson
      Participant

      I want to use this to hide blank multi-line text fields in an Edit form. I think I need some code to go in the “()” after function in the JS script that sets the condition for triggering this rule as “is not equal to [blank]”… is that correct? if so can you give me the code for that?

    • #15984
      Alexander Bautz
      Keymaster

      I’m not sure I understand exactly what you mean, but you can add this code to your EditForm Custom JS to hide and empty multiline plain text field:

      if(getFieldValue("MultilinePlainText").length === 0){
      	$("#dffs_MultilinePlainText").hide();   
      }

      Change “MultilinePlainText” with your field name.

      If you have a rich text input you can hide it like this.

      if($(getFieldValue("MultilineRich")).text().replace(/\u200B/g,"").length === 0){
      	$("#dffs_MultilineRich").hide();   
      }

      Change “MultilineRich” with your field name.

      Alexander

    • #16522
      Artaker
      Participant

      Hi,

      does this work for multilookup fields as well?

      Thanks
      BR
      Nicole

    • #16543
      Alexander Bautz
      Keymaster

      No, but it would be possible to do it in a similar way. How would you use the trigger?

      Alexander

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