Fields not clearing on HR11

 2 Replies
 0 Subscribed to this topic
 12 Subscribed to this forum
Sort:
Author
Messages
wilcoxmad
Veteran Member
Posts: 87
Veteran Member

    I created a new version of HR11 with just the required fields. I deleted all the tabs and made it a single form with just the desired fields. It works well with one exception. If you inquire before adding, the data that is not on the new form (Name prefix and sufix for example) still gets added if it exist on the employee record that was inquired on. Any ideas on how to stop this? I tried clearing those fields:

    function FORM_OnBeforeTransaction(fc)
    {
     //blank out HR11 screen fields that are not used 
      return ( fc == "A" ? initF() : true );  
    }

    function initF()
    {

    // ##################    MAIN TAB    ############################ 

    // EMP-LAST-NAME-PRE
     lawForm.setDataValue("text4","");
    // EMP-NAME-SUFFIX
     lawForm.setDataValue("text6","",0);
     // EMP-NICK-NAME
     lawForm.setElementValue("text8","",1);
     // EMP-NAME-PREFIX
     lawForm.setElementValue("text10","",3);
     // EMP-ADJ-HIRE-DATE                                                                                                                  lawForm.setElementValue("text14","",7);

    and so on.......

    For some reason this did not work. Any other ideas?

     

    John Henley
    Posts: 3353

      Your Javascript looks incorrect.

      When you use lawForm.setDataValue() you should be referencing the COBOL element, e.g.:

      lawForm.setDataValue("LINE-FC","D",0);

      When you use lawForm.setFormValue() you should be referencing an XML element, e.g.:

      lawForm.setFormValue("Fc1","A",0);

      When you use lawForm.setElementValue() you should be referencing an HTML element, e.g.:

      lawForm.setElementValue("_f21r2","Some value",2);

      Also, on some of your methods, you are including the row number and on some you're not...in the above examples, they are all for fields in the detail area of a header/detail form.  If your form is a single record only, just leave the row number off...

      When I do this type of Javascript I've found that you need to use both .setFormValue [to set the on-screen value] and .setDataValue [to set the underlying data value]. 

      So for your example I would use:

      lawForm.setFormValue("text4","");
      lawForm.setFormValue("text6","");
      lawForm.setDataValue("EMP-LAST-NAME-PRE","");
      lawForm.setDataValue("EMP-NAME-SUFFIX","");

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