Conditional DS Code Based On The Return MSG Of A Chg Function

 5 Replies
 0 Subscribed to this topic
 12 Subscribed to this forum
Sort:
Author
Messages
LCM
Basic Member
Posts: 8
Basic Member

    A little background is that I am attempting to build a custom page with DS to be used to certify effort that combines the functionality of a couple of GM screens.  I have gotten every piece of this project to work when the various functions are segregated out to their own action buttons but I am running in to trouble when I attempt to combine the various pieces in to one button (and add some conditional logic).  The problem is timing related.  Essentially functions that are called further down in my code are firing off before other functions have completed DB updates.  To address this I am trying to use return messages to better control the timing of the functions (or to stop them completely). 

     

    In the code example below the key is the Change functionality.  If all goes well the “Change Complete” message should be returned by Lawson.  However, when I execute this code the message in the alert is “Inquiry Complete”.  This message does not appear on the bottom left hand side of the portal page at any time and therefore must be a remnant of the page loading.  When I clear the alert I then see the “Change Complete” message on the bottom left of the Portal screen (but not in the alert).  If I rerun the function without refreshing “Change Complete” is now returned because it is now the last message in memory even if the subsequent change function is disallowed.  Consequently, my alert always seems to be one step behind.  I need a mechanism to ensure that the change is in fact complete before the code moves on since a subsequent AGS call is not valid unless this change is truly complete.   If anyone has any ideas on how to better approach this issue, I would be grateful for any advice.  Thanks!

     

    Code example:

     

    function doCertPop()

    {

                var certques = confirm ("Cert Language")

     

                if (certques)

                {         

                for (var i=0; i<11; i++) {

                                        if  (lawForm.getFormValue("out12",i) > valtest)

                                        {                                 

                                        NumRows = i + 1

                                        lawForm.setFormValue("fc1",'T',i);

                                        }         

                                                                 }

            lawformDoFunction("C");

                                                    var vLastMsg = lawForm.getMessage();

                                                    alert(vLastMsg);

                                                       if (vLastMsg == "Change Complete - Continue")

                                                          { 

                                                                alert("Satisfied");

                                                          }

    //          lineCount1();

                }

                else

                {

                            alert("No updates have been submitted.");

                }

    }

     

    David Williams
    Veteran Member
    Posts: 1127
    Veteran Member
      I think you're going to have to break out the section that looks for the Change Complete Message
      function FORM_OnAfterTransaction(data)
      {
      var sMsg=lawForm.getMessage()
      if (sMsg=="Change Complete - Continue")
      David Williams
      LCM
      Basic Member
      Posts: 8
      Basic Member
        Thanks for the quick response David. I tried moving the code to its own function and it still returns the “Inquiry Complete” message in the alert. Also all of my subsequent code that for example sends the AGS call mentioned above are in their own functions and they all execute before the change is "complete" in Lawson. When the functions are seperated in to different action buttons and are executed manually one at a time the whole process works great though. I'm very confused.
        wilcoxmad
        Veteran Member
        Posts: 87
        Veteran Member
          LCM, did you do it in an "FORM_OnAfterTransaction" function? I think that is the key.
          LCM
          Basic Member
          Posts: 8
          Basic Member
            The "FORM_OnAfterTransaction" was the key. I thought that I had used it yesterday but apparently not. All is working as expected with this section now. Thanks to both of you for your assistance.
            wilcoxmad
            Veteran Member
            Posts: 87
            Veteran Member
              Glad to be able to help. I'm a novice at DS.
              I am so greatful this site is here! John, David and others have helped me many times.