Creating a field that verifies values in another table

Creating a field that verifies values in another table

In this tutorial, we will see how use a field with type “Select” to checks values that are in another tables. For example, we are using two tables:

states”(that will include the values to be checkedand “city” (that will receive the values that are in states).

First we will see how is organized the table that we will use to receive the information see image that are below:



Try see that we have two fields, that 
have a relation of “Value x description”. The field stateid have the acronyms each state, the field statename have the description each state.

Now we will see the form that was created in table “city”, see image that are below:


How can see above, the table “city” have only three fields, c
ityname, stateid and statename where the field stateid will be the field used to receive the values that are in table “states”, with this way we can restrict the insert only states registered.

So, we will change the type of the data of the field stateid to “select”, accessing the left menu “Field -> stateid”:

And for finish, it's only create a SQL Select Statement in option “Lookup Settings”, in this example we are using the option Lookup Method “Automatic”, where the field stateid will the value to be insert in the database when the rows will be choose, and the field StateName will used only how description. Below have the statement generate that was used for this tutorial:

To finish this process you will have a field with the type select that will show the values of the field description of the table “states”, and will insert in the table “city” the value select of the field stateid.

 

    • Related Articles

    • Default values in Scriptcase

      In Scriptcase, default values ​​help to standardize project information, so it is much faster to create some items since there is no need to worry about features that will be standardized thanks to this important feature in our tool. Below you can ...
    • How to change the log module table

      After creating the Scriptcase log module, it is possible to change the table. When making this change, a new table will be created from scratch with no records. The records in the previous table must be migrated to your database. How to edit log ...
    • Creating a Field grouping

      See how to create groups of fields in a simple way in the query application. 1. In a grid application, access the Fields menu and click New field. 2. Set the quantity and click Continue. In this case we only need one field. 3. On the field inclusion ...
    • Add a record to another table from a condition

      1- We create a form where we will perform the validation. 2- In the OnValidate event of our form we introduce the code with this scheme if (condition == condition) { insert the data to the other table; } else { echo "no records added"; } 3- this will ...
    • Adding new columns in the table for Calendar

      If your calendar application is already created, we must add the fields below in the table so that the new functionalities work correctly: category int id_api varchar(255) id_event_google varchar(255) recur_info varchar(255) event_color varchar(255) ...