1
0
-1

I use the "Database SQL query" (Database SQL Query) ( formerly known as JDBC Form Binder) for form Data. I have 2 questions:

  1. In "load data from" it shows a "SQL SELECT query" box. Joget knowledge base (Database SQL Query) has an example that uses 
    SELECT * FROM app_fd_table WHERE id = ?
    where does the parameter (?) value come from? With a cursory search I saw that it is related to the URL parameter of the web page (UI menu) to which the form will belong. Is this right? I haven't found any documentation about. Also the parameter name must be id. Otherwise it is not recognized!
  2. In the "Save Data To" it shows a "SQL SELECT query" box. Joget knowledge base (Database SQL Query) has an example that uses
    SELECT * FROM app_fd_table WHERE id={id}

    The tooltip comment (the blue ! in the label) says "Used to decide an insert or update operation. Use syntax like {field_id} in query to inject submitted form data.". I don't understand how this is used? I assume  that when there is {id} then it is in edit mode otherwise it is in add new record mode so the fields are empty. Am I right?
    CommentAdd your comment...

    2 answers

    1.  
      4
      3
      2

      Hi Nik,

      For the load data select query the question mark (?) is indeed used as a placeholder in the query. It represents the primary key or foreign key value that will be used to fetch the specific record. 

      This placeholder will be replaced at runtime with the actual value. The value typically comes from:

      URL parameters #requestParam.paramName#
      Form fields #form.tableName.parentFormId# or other static values.


      Regarding the "Save Data To" SQL SELECT query your understanding is correct. This query is used to determine whether an insert or update operation should be performed. Here's how it works:

      If the query returns a result (i.e., a record with the specified {id} exists), Joget will perform an update operation.
      If the query doesn't return a result (i.e., no record with the specified {id} exists), Joget will perform an insert operation.

      The {id} in the query is replaced with the actual id value from the form data. This allows Joget to check if a record with that id already exists in the database. Use syntax like {field_id} in query to inject submitted form data. Initially when the records are added for the first time {id} field will be empty indicating insert query has to be executed.


      Hope this helps.

        CommentAdd your comment...
      1.  
        3
        2
        1

        Hi Nik,
        The ? represents the selected record id. If you use row actions then the selected row id will be taken and if you use grid action buttons then one or multiple selected rows ids will be placed where ? is written


          CommentAdd your comment...