Design Studio - Population of list box from a query result (8.0.3 env and 8.1 apps)

 5 Replies
 0 Subscribed to this topic
 12 Subscribed to this forum
Sort:
Author
Messages
Sreenivasa Komma
Basic Member
Posts: 19
Basic Member
    Hi,

    I have a list box field defined in design studio XML like this:



    I want to populate the list from the result set of a DME query. I don't want to code vals entries like this for the above field

    Disp="1846" Tran="1846" id="vals18">John Young

    in the XML but want to dynamically generate these using Javascript.

    Anyone did this before.

    Thanks in advance..
    Sreeni
    John Henley
    Posts: 3353
      See this post:
      https://www.lawsonguru.co...stid/52/Default.aspx
      Thanks for using the LawsonGuru.com forums!
      John
      Sreenivasa Komma
      Basic Member
      Posts: 19
      Basic Member
        John

        I can not Thank you enough for the timely help. I have been strugging to get this to work for the past 3-4 days and with the code snippet you posted I finally got a breakthrough.

        Thanks much.. I really appreciate what you are doing thru this forum.

        -Sreeni
        Sreenivasa Komma
        Basic Member
        Posts: 19
        Basic Member
          here is how I did it.

          function populateList(f)
          {
          var fieldKey;
          var hrbcRecs;
          var hrbcCode;
          var hrbcDesc;
          var arrCOL;
          var hrbcList;
          dmeStr = "?XCOLS=TRUE&XKEYS=TRUE&XCOUNT=TRUE" +
          "&XRELS=FALSE&XIDA=FALSE&XNEXT=FALSE" +
          "&PROD=" + portalObj.getUserVariable("PRODLINE") +
          "&FILE=PCODES" +
          "&FIELD=CODE;DESCRIPTION;" +
          "&INDEX=PCOSET1" +
          "&KEY=41" +
          "&SELECT=ACTIVE-FLAG%3DA" +
          "&MAX=1000" +
          "&OUT=XML";

          dmeCall = portalWnd.httpRequest(portalWnd.DMEPath + dmeStr);

          if (!dmeCall || dmeCall.status) {
          alert("System Error. Contact HRIS. Error: PCODES HRBC DME");
          return false;
          }

          dmeDS = new portalWnd.DataStorage(dmeCall);

          try {
          hrbcRecs = dmeDS.document.getElementsByTagName("RECORD");
          alert(hrbcRecs.length);
          if (hrbcRecs.length == 0)
          {
          alert("System Error. Contact HRIS. Error: No HRBC values");
          return false;
          }
          } catch(err) {
          alert("System Error. Contact HRIS. Error setting HRBC code " + err);
          return false;
          }

          hrbcCode = new Array(hrbcRecs.length);
          hrbcDesc = new Array(hrbcRecs.length);

          //_f103r0 is the above field defined with tp="Select"
          var hrbcList = document.getElementById("VALUES_f103r0");

          var tVals;
          for (var i=0; i {
          arrCOL = hrbcRecs[i].getElementsByTagName("COL");
          hrbcCode[i] = arrCOL[0].firstChild.nodeValue;
          hrbcDesc[i] = arrCOL[1].firstChild.nodeValue;
          tVals = document.createElement("span");
          tVals.setAttribute("tran", hrbcCode[i]);
          tVals.setAttribute("disp",hrbcCode[i]);
          tVals.setAttribute("text",hrbcDesc[i]);
          hrbcList.appendChild(tVals);
          }

          return true;
          }

          heidi
          Basic Member
          Posts: 12
          Basic Member

            Hello!

             

            First, I need to say how helpful Lawson Guru and all these posts are.  Reading through issues and resolutions posted here has certainly helped me, and countless others, I am sure, in getting through Lawson Design Studio questions and issues.

             

            This particular post was extremely helpful for me when creating a custom list box, based on a users location,  of selected pars from the ICLOCATION table.  The selected value is then passed to the Par Location field on IC81.1 for display/maintenance.

             

            I have one issue, however, when the returned  record set is greater than a count of 25.  It appears that the custom list box only displays the first 25, where the query would actually return a number greater than that.

             

            This populatelist function does not limit the array in any way, so the custom list box limit must be controlled elsewhere.

             

            Anyone have any ideas how I could find where it is controlled or  any work around for this to allow access to the remaining records that did not/could not display? 

            heidi
            Basic Member
            Posts: 12
            Basic Member
              I have answered my own question . . .

              The location as to where to control the number of records displaying via the custom list box has been identified.   In the DME query, I have added, "&MAX=150".  All works as expected now.