4D Blog

Home Product More sophisticated ORDA queries with formulas

More sophisticated ORDA queries with formulas

August 6, 2019

Product

In 4D v17 R6, ORDA queries are becoming increasingly more powerful and concise. This blog post is for those of you who need more sophisticated search criteria than just a simple syntax like “name = Smith‘”. With this R-release, you can use any project method or 4D expression in the query() member method by using formulas.

What better way to explain this feature than with an example? Let’s dig into the details.

HDI: Example of ORDA queries using formulas

WRITE A QUERY USING a FORMULA

The query() member method has been updated to support a single Formula object as a parameter.

Example

In the Students dataClass, we search for students with a score in English higher than their overall average score.

Note that each entity is accessed by the formula with the This command.

C_OBJECT($formula;$students)
// In the Students dataClass, grades is an object field containing students' grades for each subject
// Example of JSON representation of the grades object field:
// {math:50,english:90,history:85}
// The studentAverage project method computes the student's overall average in all subjects
$formula:=Formula(This.grades.english>studentAverage (This))
$students:=ds.Students.query($formula)

use a Formula with other search criteria

Formulas can easily be combined with other search criteria. Below is an example to show you how.

Example

In the Students dataClass, we continue to search for students with a score in English higher than their overall average AND whose country is England.

The $formula object is used as a placeholder value, like any other one.

C_OBJECT($formula;$students)
C_TEXT($country) // $country = "France"

$formula:=Formula(This.grades.english>studentAverage (This))
$students:=ds.Students.query(":1 and country=:2";$formula;$country)

use a formula in the query string

A formula can also be inserted in the query string with an eval() statement.

While this can be convenient for quickly coding a query, you’ll miss the advantages from using a formula object (such as autocompletion, colors in the code editor, and search callers).

C_OBJECT($students)
C_TEXT($country) // $country = "France"

$students:=ds.Students.query("eval(This.grades.english > studentAverage (This)) and country=:1";$country)

NOTE: The query() member method on the entity selection object has also been updated to support formulas. Check the documentation to learn more.

Discuss

Tags Formula, ORDA, v17 R6, v18

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

Avatar
Marie-Sophie Landrieu-Yvert
- Product Owner - Marie-Sophie Landrieu-Yvert joined the 4D Product team as a Product Owner in 2017. In this role, she is responsible for writing user stories and translating them into functional specifications. She also ensures that the delivered feature implementation meets the customer's needs. Marie-Sophie graduated from the engineering school ESIGELEC and began her career as an engineer at IBM in 1995. She took part in various projects (maintenance and development projects) and worked as a COBOL developer. She then moved on to work as a UML designer and Java developer. More recently, her main responsibilities included analyzing and writing functional requirements, and coordinating business and development teams.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 4D View Pro
  • AI
  • Release infos
  • 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 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Compatibility settings 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 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Compatibility settings 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