Visual Builder

Get Involved. Join the Conversation.

Topic

    Shakila Murugan
    How to populate array of elements in dropdown listAnswered
    Topic posted August 13, 2019 by Shakila MuruganBronze Medal: 1,250+ Points, tagged Action Flows, Custom Code, Services, UI, Validation 
    30 Views, 4 Comments
    Title:
    How to populate array of elements in dropdown list
    Content:

    Hi Team,

    How to populate array of elements in drop down list? I have consumed data from report. I am taking that values from looping.

    How to set that values in drop down list?

     

    Thanks

    Shakila

    Version:
    19.1.3

    Comment

     

    • Shakila Murugan

      Thanks for your response Shay.

      We are consuming report and we get value as jwt string. then i convert jwt string to readable data.Below code i used.

      PageModule.prototype.getCsvDecodeChildrenList = function(csvEncode) {
           //   alert('on method');
          console.log('BIresponse ' + JSON.stringify(csvEncode));
          console.log('BIresponse ' + JSON.stringify(csvEncode['__text']));

          var refDecode = JSON.stringify(csvEncode['__text']);
          var finalDecode = JSON.parse(refDecode);
          console.log('finalDecode--------------------' + finalDecode);
          // // Decode the String
          // var finalDecode=refDecode;
          var decodedString = atob(finalDecode);
          console.log('decoded String' + decodedString);
          return decodedString;
        };

      // Split return values here==========================
        PageModule.prototype.getchildrenList = function(allText) {
         //  alert('on method======getApproverDetMethod');
          var returnValues = [];
          var allTextLines = allText.split(/\r\n|\n/);
          console.log('Before Replace--------------------' + allTextLines);
          console.log('Before Replace0--------------------' + allTextLines[0]);
          console.log('Before Replace1--------------------' + allTextLines[1]);
          //  allTextLines=allTextLines.toString().replace("","");
          //   console.log('After Replace--------------------'+allTextLines);
          console.log('allTextLines--------------------' + allTextLines);
          var entries = allTextLines[0].split(','); //spliting column names
          //     entries=entries.toString().replace("","");
          console.log('entries--------------------' + entries);
          console.log('allTextLines.length--------------------' + allTextLines.length);
          var temp = "";
          for (var i = 1; i < allTextLines.length - 1; i++) //line by line
          {
       
            var reportData = "";
            var reportJson = "";
            var values = allTextLines[i].split(','); //spliting values  one by one
       console.log('values--------------------' + values);
            returnValues.push({
             "CHILDREN_LIST": "" + values[1] + "",
             "CHILD_NAME": values[2].replace("\"", "").replace("\"", "")
            });
          }
       
          return returnValues;
        };

      We get values in multiple rows.Then assign that return value to Array Data Provider. Now we need to set that ADP values in LOV.

      How can i achieve this.

      Thanks

      • Shay Shmeltzer

        Don't use an ADP, use a regular array and assign it to the options property of the selectOneChoice.

        As you can see in the blog/video above you can base a selectOne on an array variable in your page.

        So just have an action chain that invokes your JS function, and then assign the returned value to the array variable that populates your list.

         

    • Shakila Murugan

      Thanks Shay.

      Its working fine for me.