• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

formRender only happens once, I need it to happen more

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • formRender only happens once, I need it to happen more

    Hello everyone,
    I have a nice app going and I just hit a road block. I have a form widget from a remote database that is our Content Management system. It stores all kinds of documents and metadata for those docs. That part is working great.
    How I'm building this app is by displaying a grid of records that are approval records for these documents. 1st status is "needs to approve". I have a row icon that then loads this form widget and I use the form helper program to hide all the values except 1 and that values is created in the form helper. The values is an iframe with the URL to 1 of these documents. That also works. I'm happy with loading documents from one system in my nitro app.
    Where it stops working is when I'm done with this first document. The user presses a button that approves or denies the document, the button helper updates the system, and NAB does a "hide widget" to go back to the starting grid. The next document is then needed so the user click a row icon to "show widget" again but my form helper program does NOT kick off. My guess is that since the form was rendered once, that's it. No more. I need my form helper to kick off when the form brought up every time. I thought that the Show/Hide widgets would work, but it does not for what I need.
    I have the widget "initially hidden" so the form helper does not start when the app loads, then it runs on the first "Show" but never again. I know the form helper can run when a field is changed, but my users are not doing that. They are using a button to make an approval, and then I "hide" the widget.
    Any ideas on how I can get the form helper to run when the widget have a behavior of Show widget and load data?
    Thanks.
    Last edited by sean.lanktree; 10-12-2022, 06:35 PM.

  • #2
    I apologize for the title. I was trying to multi task.
    Title should be formRender only happens once, I need it to happen more.

    Comment


    • #3
      You can force the "formRender" action to be called again by adding an "Execute Script" behavior. Try the following steps:
      • Open your app in NAB and hover your mouse over the form in question.
      • Click the settings icon
      • Give your form a name (available on the left side options). For this example I will call it "myForm".
      • Go into Behaviors and add an "Execute Script" option at the same spot where you are showing your form.
      Your script should be:

      Code:
      var myForm = getWidget('myForm');
      
      myForm.processHelperPgm({},'formRender',null);
      success();

      Comment


      • #4
        Thanks Sean, that seems to break it. lol. Now it almost like my form helper app is not running fast enough. it loads the form without the actions the form helper is doing.
        I have the form helper in debug, usually the helper program will finish before the forms loads. now, the form loads while the helper app is still running.
        Maybe I need to be more clear with my request. I don't need the gMode to be formRender. I just need the form helper to run when I show widget every time, not just the first time. could a button program do that maybe?

        Comment


        • #5
          Actually, it looks like its causing formrender to go twice. I see my document load up in the iframe, and then it disappears. Can we condition that processHelperPgm to only run on the second time the form is shown?

          Comment


          • #6
            I see...ok. let's remove the Execute Script but leave the friendly name you gave your form.

            The following steps may be what you are after:
            • On the click of your grid (the click that shows your form), make the first action "Call RPG Program". This will be a new program based off of EXNABBTN.
            • Put the current actions that you have under the "success=true" of this new Call RPG Program action.
            The new program will allow you to interface with your form. You will first have to call: SetWidget('myForm');

            Next, you can use SetResponse to perform actions against your form (see notes in EXNABBTN).

            Code:
            SetResponse('formFieldHide':'MYFIELD');
            SetResponse('formFieldValue':'MYFIELD':'SOME_VALUE');
            etc....

            Comment


            • #7
              Thanks again Sean, I understand the technique your are talking about. Using the button helper program to manipulate the form like I was doing with the form helper. I was able to get it working. However, it seems I stumbled upon a bug IMO. The button program kicks off just fine, but the behavior I take right before the call RPG program is Filter widget. What I see in the widget is the value I set with formFieldValue for a half second and then it disappears. If I remove the filter widget, then my test values I set with formFieldValue stay. I even create a new fresh program to test this theory and was able to replicate it. No filter and it works the way I want, Adding a filter breaks it. I tried to upload a screen capture but I was denied. I can't upload a mp4 or a pptx to show you. I don't know how else to get you the screen recording I did.
              Let me know what you think.

              Comment


              • #8
                When you execute "Filter Widget" you are telling the widget to reload its data with the given filters. This would then overwrite the values you assigned to the form via your program. Why not just remove the filter of the widget if you are manually assigning the values via your program?

                Comment


                • #9
                  The reason for the filtering is because this widget is using a remote data source to my ECM system. When I filter it, there really is only 1 values I want and its an entry ID to a specific document. The values from the grid, match the values in this widget and I get this entry ID which I then use to create a URL directly to the document. This worked perfectly when I was using a form helper app, it just stopped working after the first time loading.

                  Comment


                  • #10
                    Hi,

                    Based on this thread I think for right now you should go back to what Sean was originally suggesting however with a little change to the "Execute Script" source code.

                    Originally posted by sean.lanktree View Post
                    You can force the "formRender" action to be called again by adding an "Execute Script" behavior. Try the following steps:
                    • Open your app in NAB and hover your mouse over the form in question.
                    • Click the settings icon
                    • Give your form a name (available on the left side options). For this example I will call it "myForm".
                    • Go into Behaviors and add an "Execute Script" option at the same spot where you are showing your form.
                    New suggested source:
                    Code:
                    var myForm = getWidget('myForm');
                    
                    // add listener to call form helper if the form has been rendered and only add
                    //  the listener once
                    //
                    if (myForm.rendered && Valence.isEmpty(myForm.loadlistenerSet)) {
                        myForm.loadlistenerSet = true;
                        myForm.getStore().on({
                            load : {
                                delay  : 260,
                                fn     : function() {
                                    myForm.processHelperPgm({},'formRender',null);
                                }
                            }
                        });
                    }
                    success();
                    Hopefully this will do exactly what you need...

                    Comment


                    • #11
                      Jonny, this is EXACTLY what I needed. I now have the form helper working perfectly. Every time the form loads, it displays my custom URL. I close the form and filter it again, and boom, new URL. Thank you. This is going to be so cool. I have so many more uses for this technique.
                      Thanks again both of you for the help.

                      Comment


                      • #12
                        Great,

                        The development team will discuss this specific use case and see if something can be adjusted or added in a future update so you don’t have to create a custom script.

                        Thanks for letting us know
                        Last edited by robert.swanson; 10-16-2022, 01:25 AM.

                        Comment


                        • #13
                          No problem. We use the Form widget a ton because it is so flexible. We can code almost anything we want into it. It give us the customization that we need.

                          Comment

                          Working...
                          X