This article explains the features of the "Get Data from Database" block, which allows you to fetch data from an external or organizational database and use it within your Clappia app.

The "Get Data from Database" block works within the Design App phase and connects Clappia to an external database. Once configured, it fetches data from the database dynamically when the app is used.

Click on the "Get Data from Database" block and start editing on the right panel.

The label is the name of the block that the end user sees in the app.
Example: "Fetch Employee Details" or "Get Stock Info".
The description is the additional information provided to the end user, displayed below the input area. You can also leave this blank if not necessary.
Choose the type of database you want to connect to from the dropdown.
Supported options: MySQL, PostgreSQL, AzureSql
Enter the hostname or IP address of your database server. This is typically provided by your IT team or database administrator. For example:
Specify the port number for your database connection.
Example: 3306 (MySQL) or 5432 (PostgreSQL).
Provide the login credentials required to access your database. These are assigned by your database administrator. Ensure the account has read permissions for the required tables.
Specify the name of the database where your data is stored. The name must match exactly as it appears in your database. For example, if your database is called employee_data, you must enter employee_data.
Click "Authenticate" to test the connection. If successful, additional fields will appear for query configuration.

Once authentication is successful, you can define the query to fetch data.
Example of a database table:


Write an SQL query to fetch data from the database. Use conditions to filter results dynamically.
Example:
SELECT * FROM employee_table;
Ensure that your query retrieves only the required data.

Add the column names from your database query as Output Fields. These must match the exact column names in the database.
Once Output Fields are defined, corresponding output variables are automatically generated. These variables can be used to display specific values from the database in other fields of the app.


This allows you to display specific data fetched from the database (e.g., age, email) in separate fields within the app.




This field allows you to set a custom message that will appear when no records match the query you have specified.
Example: If the query does not return any data, you can display a message like "No matching records found."
Leave this field blank if you do not wish to display a message in such cases.
Toggle this option to make the Get Data from Database block mandatory for app submission.
When enabled, users must interact with the block (fetch data and make a selection) before submitting the form.
If this option is disabled, the block becomes optional, and users can proceed without fetching or selecting data.

The Advanced Label option allows you to change the label of a field dynamically based on a condition you define. Instead of always showing the same fixed label under the ‘Basic’ tab, the field can display different labels depending on requirements of the form. Use spreadsheet-like functions such as IF, AND, OR, etc. and make use of other field variables to set your conditions. Type @ and select the field.
This is useful when the meaning of a field changes based on context, business logic, or user choices.
For example:
If you have a dropdown called Type with options “Employee Info” and “Project Info”.
The label updates based on the query chosen.
So:
– If Employee Info, show “Load Employee Info”
– If Project Info, show “Load Project Info”
Formula:
IF({type} = "Employee Info", "Load Employee Info", "Load Project Info")
This allows the same field to adapt its displayed purpose without needing multiple separate fields.
The Advanced Description option works exactly like Advanced Label, but it changes the description text instead. This is useful when guidance or instructions for a field need to change depending on earlier answers.
For example, using the same scenario from Advanced Label:
If you have a dropdown called Type with options like “Employee Info” and “Project Info”, you may want the description of your Database Lookup field to guide the user differently depending on what they selected.
So:
– If the user selects Employee Info, the description could say: “Load employee details from the database.”
– If the user selects Project Info, the description could say: “Load project details from the database.”
Formula:
IF({type} = "Employee Info", "Load employee details from the database.", "Load project details from the database.")
This helps users understand what is required from them without showing unnecessarily long or irrelevant instructions.
Additional Examples (Apply to Both Advanced Label and Advanced Description)
1. Showing nothing until a selection is made
For example, if you have a dropdown field called Visit Category with options “Routine” and “Urgent”, you may want the label or description of a field to remain blank until the user first selects a category.
Once a selection is made:
Formula (can be used in either Advanced Label or Advanced Description):
{visit_category}The label/description stays empty until the dropdown has a selected value.
After the user picks an option, the selected text (Routine or Urgent) becomes the label or description.
2. Changing label/description based on language selection
For example, if your form includes a dropdown field called Select Language with options English, Spanish, and French, you can show the label or description in the selected language.
So:
Formula (can be used in either Advanced Label or Advanced Description):
IF({select_language} = "English", "Enter details", IF({select_language} = "Spanish", "Ingrese detalles", "Entrez les détails"))The formula returns the text for the selected language.
Only one label/description is shown at a time, depending on what the user picks in the Select Language dropdown.
1. Variables do not change
When a field is created, its variable name is derived from the label you set in the Basic tab. That variable name is what you must use in formulas, workflows, and other logic. The visible label or description shown by Advanced Label / Advanced Description does not change the variable name.
2. Submissions tab: table view vs right panel
In the Submissions area, the table view always displays the labels from the Basic tab. When you open an individual submission, the right panel shows the labels and descriptions as they appear in the form (i.e., the Advanced Label and Advanced Description applied for that submission). This keeps the submission list consistent while letting reviewers see the context-aware labels and descriptions when viewing a record.
3. Bulk Edit shows Basic tab labels and descriptions
When you need to Bulk Edit submissions, the spreadsheet you download shows the labels and descriptions from the Basic tab only. Advanced Label and Advanced Description are not applied in Bulk Edit, so keep that in mind when preparing bulk updates.
4. Some fields cannot be used inside Advanced Label/Description formulas
Certain block types do not expose a variable that can be referenced in Advanced Label or Advanced Description. If a block does not expose a variable, you cannot use it inside the formula.
Geo Address
GPS Location
PaymentGateway
Audio
Live Tracking
Signature
Code Scanner
NFC Reader
Get Data from RestApi
Get Data from Other Apps
Get Data from Google Sheets
Get Data from Database
AI Block
Text, HTML & Embedding
Attached Files
Image Viewer
Video Viewer
PFD Viewer
Code block
Progress Bar
Action Button

Use this option to show or hide the field under specific conditions. It accepts the standard Clappia formulae, similar to conditional sections or in the ‘Calculations & Logic’ block.
This option appears once a condition is set in the Display this field if option. Enable this setting if you want the field's value to be retained even when the field is hidden. This is useful for preserving user input in cases where the field may temporarily disappear based on conditions.
Example: If the field is hidden based on user selection but you still need to keep the entered value for future reference or calculations, enable this option to ensure the data is retained.
This option is enabled by default. When active, end users can edit the value entered in this field after creating a submission. Disable this option if you want the initial value to remain uneditable once submitted.
Desktop View: Set the width of the PDF Viewer block in the desktop view. Options are 100%, 75%, 50%, or 25%.
Mobile View: Set the width of the PDF Viewer block in the mobile view. Options are 100% or 50%.
When the app goes live, users can interact with the "Get Data from Database" block.
L374, 1st Floor, 5th Main Rd, Sector 6, HSR Layout, Bengaluru, Karnataka 560102, India
3500 S DuPont Hwy, Dover,
Kent 19901, Delaware, USA

3500 S DuPont Hwy, Dover,
Kent 19901, Delaware, USA
L374, 1st Floor, 5th Main Rd, Sector 6, HSR Layout, Bengaluru, Karnataka 560102, India

