• 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.

How to find FILENAME in EDIT WIDGET - Initial Value Program

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

  • How to find FILENAME in EDIT WIDGET - Initial Value Program

    I want to Initialize values on ADD from edit grid Help program (EXNABIV)

    Requirement is to create a common program V_INZGRID executed as the "Initial Value Program"
    set in FILTERS when updating an EDIT GRID. This program will be set in multiple simple EDIT GRID applications.

    The idea is it will calculate default field values for different files when the user presses ADD on the edit grid.

    The INZGRID logic is
    1. Retrieve file name being used
    2. based on that filename – execute a subprocedure to populate essential fields for that file (this is calling a background business logic program with the same name as the file being processed)
    3. Then use SETVALUE to populate various fields on the screen
    I need to find out how to get the FILENAME that is being ADDed.

    Any ideas?

    Thanks in Advance,
    Nick


  • #2
    Hi Nick -

    EXNABIV template program is only used to set initial values for user filters. Just want to confirm that you are in fact using this for setting initial values on an add prompt for an edit grid?

    Comment


    • #3
      Thanks for quick reply Sean,

      YES - I am using it to set initial values on ADD prompt for edit grid.

      But I have many edit grids, so would prefer to write one program to handle these ADD processes, and this program will have a sub-proc for each file being processed.

      This is why I want to find the file name... can I get it programmatically?

      Comment


      • #4
        Hi Nick -

        I cannot see how you are using EXNABIV to set the initial values for the Edit Grid -> Add.
        This template call is only made for user filters and would never be called for edit grid add/delete/update.
        Where are you specifying this template program within NAB?

        Comment


        • #5


          UPDATE: reading your response it look like this SET INITIAL VALUES doesn't set initial values for the ADD function... so how can I do multiple fields on ADD? Any other techniques appreciated...
          Last edited by nicklitten; 06-16-2021, 12:41 PM.

          Comment


          • #6
            Thanks for the video Nick. EXNABIV is only for pre-populating user filters. It will not pre-populate values when attempting to add a record via the edit grid.

            In order to pre-populate fields in Edit Grid -> Add, you could link an app variable to the initial value of each field.

            When would you know the necessary initial values? Upon startup of the application?

            Comment


            • #7
              I get initial values when the application is running - this APP in particular has several edit grids on within the app. Depending on which BUTTON the user presses a different EDIT GRID is displayed.

              I could set the APPVARIABLES from a program call when they press the button before the grid is displayed... then if there is a way the ADD function could use app variables?

              How can I select an APPVARIABLE from the ADD screen? It only allows constants to be entered (F4 does nothing)

              note: we actually spoke about this being a nice feature that is on your to-do list - please tell me you have a beta version I can try ;)

              Comment


              • #8
                Yes, in NAB hover over one of your edit grids and click the settings icon (top left). You will then see a "Link To App Variables" button within the form on the left side of the screen. Scroll down to the "Set Field Value" section and you will see your list of fields. Here you can specify the app variable to set for each field.

                Comment


                • #9
                  Aaahhhh... that solves my problem. It's slightly painful because I now need to set app variables for every field that may be populated... but it's a way to make it work. *THANKS*.

                  Features Request -- When editing an EDITGRID | EDIT | INITIAL VALUE Let me select
                  (a) an application variable to map against the field I am selecting or
                  (b) a helper program that I can call to map values into all the fields in one go

                  Thanks again

                  Comment


                  • #10
                    FYI - you can also initialize your fields when adding a record by using the EXNABVAL template. However, these values would only be set after the user attempts to add the record so you would not see any pre-populated values if you are in fact showing these fields in the form.

                    Comment


                    • #11
                      SOLVED: I got around this by using the STARTUP PROGRAM (to prepopulate APPVARS) and the VALIDATE PROGRAM subproc(POST-ADD) to update as needed.

                      One question remains - how can I find the name of the FILE being used by an EDITGRID??

                      I got around this by reading through all the screen fields and extracting the file name - but is there a short/fast way of doing it something like:

                      filename = getappvar('file-being-used');

                      ???

                      Comment


                      • #12
                        Could your startup program set an app variable that specifies the file being used? If so, then you could call GetAppVar to retrieve it.

                        Comment


                        • #13
                          Just looked through the EXNABVAL code and noticed that there is an array named gFile. This will contain the filenames for that specific data source. So you could also access this array to determine which file(s) are being used.

                          Comment


                          • #14
                            Originally posted by sean.lanktree View Post
                            Could your startup program set an app variable that specifies the file being used? If so, then you could call GetAppVar to retrieve it.
                            This is exactly how I solved this problem for myself...

                            Would be nice to use the gFile Array - so I will investigate that.

                            Thanks Sean!

                            Nick

                            Comment

                            Working...
                            X