Data query + User Interface Designer

 24 Replies
 0 Subscribed to this topic
 12 Subscribed to this forum
Sort:
Author
Messages
khart
Advanced Member
Posts: 25
Advanced Member
    Is there a way to use the portal page designer and the formlet function in that toolbox to map data?  I have a Lawson form built then brought it onto the portal page designer  using the formlet function but I can not get those two pieces to "talk" together...has anyone done this before?  My data query returns rows of data so when I click on a row or click on the check box I would like it to be mapped to the Lawson form.  I can gather all the data into variables from the row click but I can not pass it to the formlet.
    David Williams
    Veteran Member
    Posts: 1127
    Veteran Member
      Yes, you can map data from a DME to your formlet. Shoot me an email and I'll put together some screen shots for you.
      David Williams
      khart
      Advanced Member
      Posts: 25
      Advanced Member
        Thanks, email sent.
        SusanB
        New Member
        Posts: 4
        New Member
          I'm trying to do this same thing with no luck.  I was wondering if you'd be willing to share the same screen shots with me.  I have modified a portal page to include a formlet displaying company # and deposit date. The portal page has a header and detail section plus the formlet. Company comes from the detail query and deposit date from the header query.  The formlet deposit date field will allow the user to modify the deposit date.  I'm not able to populate the formlet.  I don't know how to capture that data.  I would really appreciate any guidance you have to offer.
           Thank you!
          Scooter
          Veteran Member
          Posts: 83
          Veteran Member
            David, could you share the screenprints to me?  It could be useful to resolve another issue that I submitted to this forum today?
            David Williams
            Veteran Member
            Posts: 1127
            Veteran Member
              Shoot me an email to David@ConsultDavidW.com or david.williams@bailsllc.com and I'll send you the documentation sometime today.
              David Williams
              Demi
              Veteran Member
              Posts: 67
              Veteran Member
                I too, would be interested in acquiring some doc. on this; if you would be willing to share it further. I am at demichener@co.bucks.pa.us.
                Clement
                New Member
                Posts: 2
                New Member
                  Hi David. 

                  I am also interested in the solution!  I just sent you an email..  Thanks for your help!
                  heidi
                  Basic Member
                  Posts: 12
                  Basic Member
                    Hello, David,

                    Might I request a copy of the documentation you have provided for DME/query in Lawson Design Studio User Interface?

                    I am new to the product, so any help would be cheerfully appreciated.

                    One of my first efforts in LDS involves a need to retrieve related dataset and display on form or in a message box.

                    My email address is: hsimon@meridianhealth.com

                    Regards,

                    Heidi
                    David Williams
                    Veteran Member
                    Posts: 1127
                    Veteran Member
                      Heidi - I just emailed you a document with examples of how to use JavaScript to perform a DME call.
                      David Williams
                      heidi
                      Basic Member
                      Posts: 12
                      Basic Member
                        Thank you very much for the information, David. It is very much appreciated.

                        New to Design Studio, I am trying to get my first DME call function to work.
                        So far, unsuccessful . . .

                        Below is a modification of a function that appeared in the Lawson DS document, "Add data query results to a form". I can not save it, as the system indicates that there is an issue in the line where the results are parsed ("length -1") The line appears to be the same as what was in the documentation.

                        Any help/direction would be cheerfully accepted.

                        Heidi


                        function BUTTON_OnClick(id, row)
                        {
                        if (id == "push3")
                        {
                        alert("New Button Pressed");
                        var sVendor = lawForm.getDataValue("MRH-VENDOR");
                        alert(sVendor);

                        //Do DME Call
                        var s = DMEPath+"?PROD=";
                        s += top.lawsonPortal.getUserVariable("PRODLINE");
                        s += "&FILE=APVENMAST";
                        s += "&FIELD=VENDOR_STATUS"
                        s += "&SELECT=VENDOR=" + sVendor;
                        s += "&OUT=CSV&DELIM=~&NOHEADER"
                        alert(s);

                        var sReturn = top.httpRequest(s);
                        lawForm.setFormValue("text52","");

                        if (!sReturn || sReturn.status > 400 )
                        return;
                        sReturn = sReturn.replace(/\r/g."");
                        aRecs = sReturn.split("\n");
                        aRecs.pop();
                        aRecFields = aRecs[aRecs.length -1].split("~");
                        if (ARecFields[0] != "")
                        lawForm.setFormValue("text52",aRecFields[0];
                        }
                        return true;
                        }
                        heidi
                        Basic Member
                        Posts: 12
                        Basic Member
                          Oh, the error received is "Expected Identifier".
                          David Williams
                          Veteran Member
                          Posts: 1127
                          Veteran Member
                            The script sample you are looking at is for version 8.03 of Design Studio. The docs I sent you should have the v9 syntax.
                            David Williams
                            heidi
                            Basic Member
                            Posts: 12
                            Basic Member
                              Thank you for clarifying! I was getting quite confused with the approaches taken in the different documents. A variation of the v9 syntax example is shown below. This time, the script was able to be saved. However, this time, when testing the form, a message "Servlet Xpress reported: Missing required parameter: _TKN" appears. Any ideas what caused this message to be produced?

                              function BUTTON_OnClick(id, row)
                              {
                              if (id == "push3")
                              {
                              alert("New Button Pressed");
                              var sVendorGroup = "VND1";
                              var sVendor = lawForm.getDataValue("MRH-VENDOR");
                              alert(sVendor);

                              //Do DME Call
                              var vProd = portalWnd.oUserProfile.getAttribute("productline");
                              var DmeString = "?PROD=" + vProd + "&FILE=APVENMAST"+ "&FIELD=VENDOR_STATUS;&SELECT=VENDOR^%3D" + sVendor + "&XCOLS=TRUE&XKEYS=TRUE&XRELS=TRUE&XCOUNT=TRUE&XIDA=TRUE&OUT=XML"
                              var vDMEInfo = portalWnd.httpRequest(portalWnd.DMEPath + vDmeString)
                              var vObjDMEXML = new top.DataStorage(vDMEInfo)
                              var vRecords = vObjDMEXML.document.getElementsByTagName("RECORD");
                              var numRec= vRecords.Length;

                              if(numRec!=0)
                              {
                              varAlert = ""

                              for (i=0;i {
                              var vCols = vRecords.getElementsByTagName("COL");
                              var vVenStatus = vCols[0].firstChild.data;
                              vAlert += "Vendor Status: " +vVenStatus + "\n"
                              }
                              alert(vAlert)

                              }

                              }
                              return true;
                              }
                              David Williams
                              Veteran Member
                              Posts: 1127
                              Veteran Member
                                I usually see that based upon where the return true command is placed in the script. To avoid it I usually just return true when the text field or button is NOT the one I want - so in your example, I would use - if (id!="push3") return true - and then add the code I want in the rest of the function.
                                David Williams
                                heidi
                                Basic Member
                                Posts: 12
                                Basic Member
                                  I made the change, however I am still seeing the same error message. Not sure what to try now . . .

                                  New script:

                                  function BUTTON_OnClick(id, row)
                                  {
                                  if (id != "push3") return true;
                                  {
                                  alert("New Button Pressed");
                                  var sVendorGroup = "VND1";
                                  var sVendor = lawForm.getDataValue("MRH-VENDOR");
                                  alert(sVendor);

                                  //Do DME Call
                                  var vProd = portalWnd.oUserProfile.getAttribute("productline");
                                  var DmeString = "?PROD=" + vProd + "&FILE=APVENMAST"+ "&FIELD=VENDOR_STATUS;&SELECT=VENDOR^%3D" + sVendor + "&XCOLS=TRUE&XKEYS=TRUE&XRELS=TRUE&XCOUNT=TRUE&XIDA=TRUE&OUT=XML"
                                  var vDMEInfo = portalWnd.httpRequest(portalWnd.DMEPath + vDmeString)
                                  var vObjDMEXML = new top.DataStorage(vDMEInfo)
                                  var vRecords = vObjDMEXML.document.getElementsByTagName("RECORD");
                                  var numRec= vRecords.Length;

                                  if(numRec!=0)
                                  {
                                  varAlert = ""
                                  for (i=0;i {
                                  var vCols = vRecords.getElementsByTagName("COL");
                                  var vVenStatus = vCols[0].firstChild.data;
                                  vAlert += "Vendor Status: " +vVenStatus + "\n"
                                  }
                                  alert(vAlert)
                                  }
                                  }
                                  }
                                  Robert Spurr
                                  Veteran Member
                                  Posts: 130
                                  Veteran Member
                                    I jumped in late to this conversation but the error message you are getting is the same message you get if you don't link the button to a function.
                                    In the designer:
                                    1) Click on the button
                                    2) Select the actions from the properties
                                    3) Select Function on left
                                    4) paste in "BUTTON_OnClick" without the quotes

                                    Of course if this is not the problem please ignore. Hope This Helps.

                                    Robert
                                    heidi
                                    Basic Member
                                    Posts: 12
                                    Basic Member
                                      Thank you, robert. The function is linked to the button. When I click the button, it begins to step through the function. However, it bails out with the "Token" required message.

                                      Are you aware of any sample code that I could try in order to obtain a "proof of concept" for accessing a piece of related data not currently on the form, and then displaying the output on the custom form?
                                      Robert Spurr
                                      Veteran Member
                                      Posts: 130
                                      Veteran Member
                                        If your willing to try, I've included a script I use in IC12.1 to populate some of the cost/qty information on the main form so they don't have to drill. For your test you could probably just convert what I have as text fields to alerts.

                                        Let me know if this helped.

                                        function FORM_OnAfterTransaction(data)

                                        {
                                        var vCompany = lawForm.getDataValue("ITL-COMPANY");
                                        var vLocation = lawForm.getDataValue("ITL-LOCATION");
                                        var vItem = lawForm.getDataValue("ITL-ITEM");
                                        var strPDL = portalWnd.oUserProfile.getAttribute("productline");

                                        //DME call
                                        var s = "?PROD="+strPDL;
                                        s += "&FILE=ITEMLOC";
                                        s += "&INDEX=ITLSET1&KEY=" + vCompany + "=" + vLocation + "=" + vItem;
                                        s += "&FIELD=LAST-REC-COST;LAST-ISS-COST;SOH-QTY;ALLOCATABLE";
                                        s += "&MAX=1&OUT=XML";
                                        //alert(s);
                                        var sReturn = portalWnd.httpRequest(portalWnd.DMEPath + s);

                                        if (!sReturn || sReturn.status)
                                        {
                                        var msg="Error calling DME ";

                                        msg += (sReturn
                                        ? "(status code): " + sReturn.status
                                        : "bad server response.");
                                        alert(msg);
                                        return true;
                                        }

                                        var vObjDMEXML = new portalWnd.DataStorage(sReturn);

                                        var vRecord = vObjDMEXML.document.getElementsByTagName("RECORD");

                                        if (vRecord.length == 0)
                                        {
                                        return true;
                                        }

                                        lawForm.setDataValueById("text47","");
                                        lawForm.setDataValueById("text48","");
                                        lawForm.setDataValueById("text49","");
                                        lawForm.setDataValueById("text50","");

                                        vCols = vRecord[0].getElementsByTagName("COL");

                                        lawForm.setFormValue("text47",vCols[2].firstChild.data);
                                        lawForm.setFormValue("text48",vCols[3].firstChild.data);
                                        lawForm.setFormValue("text49",vCols[0].firstChild.data);
                                        lawForm.setFormValue("text50",vCols[1].firstChild.data);

                                        return true;
                                        }
                                        heidi
                                        Basic Member
                                        Posts: 12
                                        Basic Member
                                          Robert, Thank you very much! I will give this a shot and let you know how I make out. Your help is really appreciated.
                                          heidi
                                          Basic Member
                                          Posts: 12
                                          Basic Member
                                            Robert, Data values were returned!!! This is a break through! Thank you so, so much for your time and attention.

                                            Unbelievably, though, the same error message box still pops up before displaying the information. I don't know how to address this error message. Is there a way to suppress the message, given that the system actually does return results now?

                                            I am thrilled to have finally "made contact" with other Lawson tables accessed from a custom form. It opens up a whole new world.

                                            Again, your help, and that of David Williams, has been invaluable to me. Thank you both! And, thank you Lawson Guru.

                                            Heidi
                                            Robert Spurr
                                            Veteran Member
                                            Posts: 130
                                            Veteran Member
                                              I beginning to believe this has nothing to do with the DME and more to do with the form. I would start over by deleting your current design studio form and regenerating a fresh copy. Validate it works before entering any scripting or buttons.

                                              Did you try the script I provided on IC12 and that is were you got the error?
                                              heidi
                                              Basic Member
                                              Posts: 12
                                              Basic Member
                                                Robert, Yes, I used your script "right out of the box", with exception of calling it from a Button Click, as opposed to the "OnAfterTransaction".

                                                I started with a fresh, new form, as I had not yet done any work on any of the IC12 forms. I added four text boxes that matched where you output the DME values.
                                                Then, a new button was added, to retrieve the data.

                                                Your script worked like a charm!

                                                I am working in our testing environment, where there are multiple productlines. Could the errant message have something to do with that?
                                                Robert Spurr
                                                Veteran Member
                                                Posts: 130
                                                Veteran Member
                                                  I guess it could be. Alert the product line and verify or for testing purposes hard code the product line to test.
                                                  heidi
                                                  Basic Member
                                                  Posts: 12
                                                  Basic Member
                                                    While I don't have a full solution yet to share, it appears that the errant, unnecessary message may be caused by a LID run type "pgmdef" setting. Once the issue is fully resolved, I will post what it took to resolve.

                                                    Again, your help and time is appreciated!