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

NAB Forms - Fields Linked to App Variables?

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

  • NAB Forms - Fields Linked to App Variables?

    Sometimes we just need to collect a little data for filtering or use by a backend helper app, and it is not always directly related to a data source field....

    I think it would be useful if we could define a field on the form that is independent from the data source and can be used for setting App Variables.

    Thanks!

  • #2
    Sorry, I am not entirely clear. Can you explain your use case a bit more as maybe we have a solution?

    Comment


    • #3
      No worries...

      Let's say I have a grid showing detail records for a specific Customer. The customer is selected from a filter dropdown list..

      I would like to have a button for Add New Customer that opens a form with a couple of fields, say customer name and number. The form button will add it to the database.

      Right now I have to link form fields to a database field, which limits flexibility when trying to gather user input on an ad-hoc basis.

      Make sense now? Or am I missing something obvious on how I should be handling something like this?

      Thanks!

      Comment


      • #4
        Sorry for the late response on this...somehow got lost by me.

        You can achieve this now with the following steps:
        • Create your "Add Customer" button
        • On Click: Call RPG Program
          • Prompt For More Info
          • Add 2 prompt fields: Customer Name and Customer Number
            • For this example, specify parameters names as customerName and customerNumber
          • Create your RPG program using EXNABBTN as your template.
        Code:
        lCustomerName           s          30a
        lCustomerNumber         s           9s 0
        lExists                 s            n
         /free
          lCustomerName   = vvIn_char('customerName');
          lCustomerNumber = vvIn_num('customerNumber');
        
          // some validation....check if name already exists
          //
          exec sql select 1 into: lExists from MY_FILE where 
                        MY_FIELD =: lCustomerName;
          if lExists;
             SetResponse('success':'false');
             SetResponse('msg':'Customer name already exists');
             return;
          endif;
          // more validation.....
        
          // all validation has passed...write out the new record
          //
          exec sql insert into MY_FILE values(:lCustomerName,:lCustomerNumber);
        
          SetResponse('success':'true');
          SetResponse('info':'Customer ' + %trim(lCustomerName) + ' has been added');
         /end-free

        Comment


        • #5
          Got it - thanks!

          Comment

          Working...
          X