3 Replies Latest reply on Aug 10, 2015 11:16 AM by Magus069

    Recognize key words in value and reference later in form, real time

    techwriter1234

      How do I make my form recognize certain key words in the value that the user types and reference that value later in a table, real time? There is a more complex scenario to add to this once this issue is resolved. I can give examples should I get a response. Thank you.

        • 1. Re: Recognize key words in value and reference later in form, real time
          Magus069 Level 4

          Hi there,

           

          to be able to find some key words in a field using strings, you can use the function indexOf();

          This function is known to return the index of a value inside an array, for a string the indexOf() function is used to return the index of the first character where the value is found...

           

          E.g.:

          TextField Value : Find this in my value

          TextField.rawValue.toString().indexOf("this"); //indexOf function will return 5

          TextField.rawValue.toString().indexOf("thisis"); //indexOf function will return -1

          If your value is found in the string, it will return its index, but if there is no instance of the value you are looking for, it will return -1 (false)

           

          So..

          if (TextField.rawValue.toString().indexOf("this") > -1){     //if "this" is found in the textfield, it will return true because the index is greater than -1

           

          } else {

               //Here, "this" was not found, so it returned false

          }

           

           

          Hope this help!

          • 2. Re: Recognize key words in value and reference later in form, real time
            techwriter1234 Level 1

            Thank you Magus069,

            This is getting me I the right direction, I'm just not there yet. here is my reply from another post I made last week taking it one step farther in the scenario.

            "I have attached screen shots from my form in run-time as well as my hierarchy. My form is really a template for Engineers who will need to fill this out and there will be many cases where the user will need to add additional text fields (add instances) using a click event. Later in the template, I have tables that need to reference the value of text fields within each instance should the value be "critical". However, since the user will be adding instances, I don't know how to reference the value of a new instance at run-time. I can send you more in an email if this doesn't make sense. Thank you for your time and help! I have only taught myself everything with LiveCycle so please be patient if I don't understand conclusions. My apologies in advance. Thanks again!

            Capture.JPG

            Capture2.JPG

            • 3. Re: Recognize key words in value and reference later in form, real time
              Magus069 Level 4

              Hi again,

               

              to be able to get through each instances you need a loop, and if you have more instances inside 1 instance, you will need to make more than 1 loop

              If I understand well what you are trying to do, your code should look something like this : (But before doing this, please rename your (untitled Subform) (page 3) to Main or Page3

               

              //For each instances of Designlevel1

              for (var i = 0 ; i < Page3._Designlevel1.count; i++){

                   //Store Designlevel1's instance in a variable

                   var myDesignLevel1 = Page3.resolveNode("Designlevel1[" + i.toString() + "]");

                   //For each PerfCap in the instance of Designlevel1

                   for (var ii = 0 ; ii < myDesignLevel1._PerfCap.count; ii++){

                        //Store PerfCap's instance in a variable

                        var myPerfCap = myDesignLevel1.resolveNode("PerfCap[" + ii.toString() + "]");

                        //For each Level3 in the instance of PerfCap

                        for (var iii = 0 ; iii < myPerfCap._Level3.count; iii++){

                             //Store Level3's instance in a variable

                             var myLevel3 = myPerfCap.resolveNode("Level3[" + iii.toString() + "]");

                             //Verify if Label contains "critical"

                             if (myLevel3.Label.rawValue.toString().toLowerCase().indexOf("critical") > -1){

                                  //Critical was found in Level3, add code here

                             }

                        }

                   }

              }

               

              I hope this is what you are looking for, if not it should be pretty much similar to what you want to do!

              Hope this help!