How to retrieve values from a DME Call

Sort:
You are not authorized to post a reply.
Author
Messages
agersh
Veteran Member
Posts: 81
Veteran Member

    How to retrieve values from a DME Call

     

    In the following Javascript function I am writing the DME Call selects 2 fields from the HRHISTORY table. I need some assistance with what programming is needed to retrieve, reference the return records/field values from the DME query.

     

    Also should the DME call output be in CVS or XML format?

    function myDMECall()
    {
         var vCompany = lawForm.getDataValue("text1");
         var vEmployee = lawForm.getDataValue("text2");
         var vAdjHireDate = lawForm.getDataValue("text14");
         alert(vCompany + ", " + vEmployee + ", " +vAdjHireDate);
     
          // DME Call
          var s = portalWnd.DMEPath;
          s += "?PROD="+strPDL;
          s += "&FILE=HRHISTORY";
          s += "&FIELD=BEG%2DDATE;A%2DVALUE";
          s += "&SELECT=COMPANY=" + vCompany + "%26EMPLOYEE=" + vEmployee + "%26FLD%2DNBR=20" + "%26BEG%2DDATE%3E%3D" + vAdjHireDate;
          s += "&OUT=CSV&DELIM=~&NOHEADER&MAX=2";
          alert(s);
     
          var sReturn=portalWnd.httpRequest(s);

          ....
    }

    David Williams
    Veteran Member
    Posts: 1127
    Veteran Member
      Use XML and something like the following to parse your data

      var vDMEInfo=portalWnd.httpRequest(portalWnd.DMEPath + vDME)
      var objDME=new portalWnd.DataStorage(vDMEInfo)
      var vRecords=objDME.document.getElementsByTagName("RECORD")
      var l=vRecords.length
      for (i=0;i {
      vCols=vRecords.getElementsByTagName("COL")
      comp=vCols[0].firstChild.data
      }
      David Williams
      agersh
      Veteran Member
      Posts: 81
      Veteran Member

        Hi David,

        Thanks for the code snip.

        For some reason the For loop is not making sense to me. A few questions... 

            What is the test condition for the loop (i=0,i &hellip ?

            Shouldn't there be an increase value for the loop ex. (i++) ? 

            I am assuming that the "comp=vCols[0].firstChild.data" should be "comp=vCols.firstChild.data" so     that the loop index is referenced. Is my assumption correct? 

            When is the l variable used? 

         

        David Williams
        Veteran Member
        Posts: 1127
        Veteran Member

          The vCols[0].firstChild.data is correct and it references the first data element in your DME call. 0=first field, 1=second field

          Send me an email david@consultdavidw.com and I'll email you my script sample

          David Williams
          You are not authorized to post a reply.