4D Blog

Home Product Building Forms on the fly with New Data Source Commands

Building Forms on the fly with New Data Source Commands

July 15, 2025

Product Illustration of developers building a dynamic interface on a large screen, representing 4D 20 R10’s new formula-based data source support for form objects.

In application development, it is often necessary to build forms dynamically. For example, you might want to generate a search form on the fly, tailored to the user’s needs. In 4D, there are two main approaches for building dynamic forms: either constructing the entire form programmatically or adding objects to an existing form layout. For the second option, until now, it was possible to duplicate objects with OBJECT DUPLICATE, and modify the data source with OBJECT SET DATA SOURCE, all using a classic pointer-based approach.

With 4D 20 R10, new and powerful commands, OBJECT SET DATA SOURCE FORMULA and OBJECT Get data source formula, allow developers to bind a formula as the data source of form objects. Moreover, you can dynamically assign formulas to key listbox properties with the LISTBOX SET PROPERTY command such as Current item, Current item position, and Selected items.

This opens the way to a more modern, flexible and readable approach, thanks in particular to expressions such as Form.xx or the classes.

HDI_SetDataSourceFormula

New commands to manipulate the data source property

Two new commands have been added to modify the data source property:

OBJECT SET DATA SOURCE FORMULA ( {* ;} object ; formula)
OBJECT Get data source formula ( {* ;} object) : formula

Example 1: Update the formula

Let’s imagine we have a text input named “myInput” in a form, and we want to bind its data source to the “Form.myText” formula.

$myFormula:=Formula(Form.myText)
OBJECT SET DATA SOURCE FORMULA(*; "myInput"; $myFormula)

Example 2: Retrieve the formula

To retrieve the formula associated with a form object, such as a text input named “myInput”, you can simply write:

$formula:=OBJECT Get data source formula(*; "myInput")

These new commands facilitate the creation of generic, reusable form templates that can be configured dynamically.

Extended Capabilities for ListBoxes

These properties are accessible using the following constants with LISTBOX Get property and LISTBOX SET PROPERTY commands:

  • lk current item expression
  • lk current item pos expression
  • lk selected items expression

 

Example:

LISTBOX SET PROPERTY(*; "myListBox"; lk selected items expression; "Form.selectedItems")

Conclusion

With OBJECT SET/GET DATA SOURCE FORMULA and the new listbox property constants, 4D provides a new, elegant, and powerful way to build dynamic interfaces.

By embracing formulas and object-oriented programming, you can now create forms that are more adaptable, maintainable, and easier to read.

Discuss

Tags 20 R10, 21, Formula, Listbox, Programming

Latest related posts

  • February 3, 2026

    4D Write Pro – Adding a margin automatically when bullets are set using standard actions

  • January 22, 2026

    Transform Static Documents into Actionable Knowledge with AIKit

  • January 22, 2026

    Deploy Fluent UI effortlessly in your 4D applications

Vanessa Talbot
Vanessa Talbot
• Product Owner •Vanessa Talbot joined 4D Program team in June, 2014. As a Product Owner, she is in charge of writing the user stories then translating it to functional specifications. Her role is also to make sure that the feature implementation delivered is meeting the customer need.Since her arrival, she has worked to define key features in 4D. She has worked on most of preemptive multi-threading new features and also on a very complex subject: the new architecture for engined application. Vanessa has a degree from Telecom Saint-Etienne. She began her career at the Criminal Research Institute as a developer for the audiovisual department. She has also worked in media and medical fields as expert in technical support, production as well as documenting new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • AI
  • 4D View Pro
  • 4D Write Pro
  • Email, Microsoft 365, Gmail
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • 4D Qodly Pro
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 21 21 R2 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Google Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 21 21 R2 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Google Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor
Subscribe to 4D Newsletter

© 2026 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

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