Form won't load new data on initial INQ

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

    I created a new HR11 screen to display the Job Class and its description, on the 2nd tab. The first time the program is initialized, these new fields don't get filled out. On any subsequent trans they work fine. Any suggestions?

     

    John Henley
    Senior Member
    Posts: 3348
    Senior Member

      <!-- Converted from text/plain format -->

      How are you loading the fields? Are you using JavaScript?

      Thanks for using the LawsonGuru.com forums!
      John
      wilcoxmad
      Veteran Member
      Posts: 87
      Veteran Member

        function FORM_OnAfterTransaction(data)
        {
         //was transaction successful?
         if (formState.agsError) return;
         
         var vCompany=lawForm.getFormValue("text1");
         var vJobCode=lawForm.getDataValue("EMP-JOB-CODE");

         // blank out jobclass and desc fields.
         lawForm.setFormValue("text165","");
         lawForm.setFormValue("text166","");

         //Find the jobcode record 
         dmeStr = "?XCOLS=TRUE&XKEYS=TRUE&XCOUNT=TRUE" +
         "&XRELS=FALSE&XIDA=FALSE&XNEXT=FALSE" +
         "&PROD=" + portalObj.getUserVariable("PRODLINE") +
         "&FILE=JOBCODE" +
         "&FIELD=JOB-CLASS" +
         "&INDEX=JBCSET1" +
         "&KEY=" + vCompany + "=" + vJobCode +
         "&OUT=XML";

          var vDMEInfo = top.httpRequest(top.DMEPath + dmeStr);

         //Set the DME result data to an XML object to parse through.
         var DMEobj = new top.DataStorage(vDMEInfo);
         var vRecords = DMEobj.document.getElementsByTagName("RECORD");
         if (vRecords.length == 0)
         {
          alert("No JOBCODE record found.");
          return true;
         }
         else
         {
         // alert("JOBCODE record found.");
          var vCols = vRecords[0].getElementsByTagName("COL");
          //get jobclass from XML object.
          vJobCls = vCols[0].firstChild.data;
          lawForm.setFormValue("text165",vJobCls); 
         }


         //Find the jobclass record
         dmeStr = "?XCOLS=TRUE&XKEYS=TRUE&XCOUNT=TRUE" +
         "&XRELS=FALSE&XIDA=FALSE&XNEXT=FALSE" +
         "&PROD=" + portalObj.getUserVariable("PRODLINE") +
         "&FILE=JOBCLASS" +
         "&FIELD=DESCRIPTION" +
         "&INDEX=JCLSET1" +
         "&KEY=" + vCompany + "=" + vJobCls +
         "&OUT=XML";

         var vDMEInfo = top.httpRequest(top.DMEPath + dmeStr);

         //Set the DME result data to an XML object to parse through.
         var DMEobj = new top.DataStorage(vDMEInfo);
         var vRecords = DMEobj.document.getElementsByTagName("RECORD");

         if (vRecords.length == 0)
         {
          alert("No JOBCODE record found.");
          return true;
         }
         else
         {
         // alert("JOBCLASS record found.");
          var vCols = vRecords[0].getElementsByTagName("COL");
          //get jobclass from XML object.
          vJobClsDesc = vCols[0].firstChild.data; 
          lawForm.setFormValue("text166",vJobClsDesc);
          return true;
         }
        }

        John Henley
        Senior Member
        Posts: 3348
        Senior Member
          I will go out on a limb and say that the reason it might not be working on the first inquire is because: 1) you're using FORM_OnAfterTransaction() event 2) you're using lawForm.getFormValue("text1") to get the COMPANY for your lookups My understanding of FORM_OnAfterTransaction is that it fires AFTER the AGS transaction has executed, but BEFORE the form fields/HTML elements are populated with the results of the AGS transaction. So, in other words, lawForm.getDataValue() will have AGS-supplied values, but lawForm.getFormValue() won't. Just a hunch. So, try changing: var vCompany=lawForm.getFormValue("text1"); To var vCompany=lawForm.getFormValue("EMP-COMPANY");
          Thanks for using the LawsonGuru.com forums!
          John
          wilcoxmad
          Veteran Member
          Posts: 87
          Veteran Member

            I'll try that but I do know that both values load correctly, I displayed the results during my testing to be sure! Company is of course a required field, so I didn't have to rely on the resulting load of data, the user must enter it.

            wilcoxmad
            Veteran Member
            Posts: 87
            Veteran Member
              Ok, I changed it to this: var vCompany=lawForm.getDataValue("EMP-COMPANY");

              (I assume you meant getDataValue not getFormValue in you response).

              Same results as I described above.

              John Henley
              Senior Member
              Posts: 3348
              Senior Member
                Try putting this in before you the lawForm.SetDataValue() functions
                lawForm.setActiveTab('TF0-1');
                Thanks for using the LawsonGuru.com forums!
                John
                wilcoxmad
                Veteran Member
                Posts: 87
                Veteran Member

                  Thanks John, that worked.

                  I also added another lawForm.setActiveTab('TF0-0'); statement, near the bottom, to make the Main tab be the one that appears first.

                  Thanks for your help! Mark.

                  wilcoxmad
                  Veteran Member
                  Posts: 87
                  Veteran Member

                    Any other ideas here? The users were not happy when the main tab is always the one they see no matter which tab they started on.

                    TIA! 

                    You are not authorized to post a reply.