Tips & Tricks for your 4D Apps – February 2023 Edition
by Add Komoncharoensiri, Director of Technical Services at 4D Inc
Here we go with another set of tips and tricks.
The 4D Knowledge Base is a library of information about 4D technology where weekly tech tips and monthly tech notes are actively published. If you missed the last tips on the KB, that’s fine; here is a compilation from the past few weeks.
This blog post covers 20 tips:
4D for Mobile Tutorial – Choose an Input Control
Formatters allow you to format the displayed data or to define behavior when the user touches the data. The input controls follow the same principle. They allow you to select the type of keyboard, define the behavior, or format the data in an action form.
For example, for image data, you have by default two types of control, the first one allows you to select an image or to take a picture, and the second one displays a zone to sign.
There are 3 types of input controls:
4D for Mobile Tutorial – Create actions
Actions allow users to interact with the application to change the customer’s address, add a new contact and modify a picture.
In the 4D language, an action allows you to add, edit, and delete an entity or a selection entity. But also, it can simply execute a method of your 4D server.
4D for Mobile Tutorial – Include relations
The data of your application are linked together by two types of relationship: Many to One or One to Many.
In this blog post, we will show you how to include relations. With 4D for Android and 4D for iOS, you can easily navigate between your related data. We automatically generate the transition between views in your application.
4D for Mobile Tutorial – Using Formatters
A data formatter allows you to map a data type from your database to a specific display on the mobile side. For example, you can define a date, percentage, or currency format. Data formatters can also call some code to create intelligent interfaces.
For example, you can attach a data formatter to phone numbers that open an action menu on the mobile app when the user touches the number (e.g., to call the person or save them in contacts).
You have three formatter types:
4D for Mobile Tutorial – Sort your list view
To facilitate the use of an application, the data presented to the user is usually sorted alphabetically, chronologically, or a combination of several criteria.
4D for Android and 4D for iOS allows you to define multiple sorts for each list view.
Catch errors everywhere
Error management is often a constraining part of development in all languages. In 4D, if you forget to call an error-handling method in a new process/worker or use components that don’t handle errors, the built-in 4D error dialog can appear to the final user. 4D developers would like to catch all errors in all contexts to avoid displaying this built-in 4D error dialog.
Let’s see how we can manage this behavior with 4D v19 R8.
4D for Mobile Tutorial – Define filter queries
For a mobile application, data is usually filtered to preserve storage space and provide direct and quick access to essential data.
With 4D, you have two types of filters.
- A static filter to filter the data for a table. For example, limit to tasks with the status ‘in progress.’
- A dynamic filter depends on the user’s information. For example, return only the user’s tasks.
This tutorial will show you how to use and combine these two filters.
Contact us
Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!
* Your privacy is very important to us. Please click here to view our Policy