4D Blog

Home Product ORDA and 4D Write Pro : The power couple!

ORDA and 4D Write Pro : The power couple!

April 27, 2022

Product

4D Write Pro documents often contain formulas returning data or calculations depending on the database. Thanks to the use of contexts, associating that data with documents is now child’s play!

In this blog post, we’ll see how the combination of 4D Write Pro documents with data retrieved using ORDA makes the code clear and easy to maintain.

ORDA and 4D Write Pro In Action

4D Write Pro and data

Whether you’re dealing with letters, e-mail campaigns, catalog generation, invoice printing, etc., the data displayed or printed always comes from the database. Thanks to ORDA, access to that data is more and more efficient, and the new concept of contexts will allow you to efficiently exploit the information in your documents.

A context? What is A context?

A context is an object: An entity, an entity selection, or any object composed of as many attributes as necessary. Once created and associated with a document, this context can be used directly within the document using the This function, which you are now familiar with.

A simple case: Mailing CAMPAIGN

Let’s say you have a People dataclass and you want to send e-mails to a selection of these people. The first thing to do is to create the letter template with the information to be communicated, and then insert data from each person (their name, address, etc.) in that template. This process is well known, but we’ell see how to insert this information once the context is created.

For each person…

Before printing your template letter, associate each entity of your selection with the template.
And that’s it!

For each ($person; $es_people)
 WP SET DATA CONTEXT($template; $person)
 WP PRINT($template)
End for each 

But what does the model contain?

The $person context is accessible in the model via the This.data formula.
If the $person entity has a lastname attribute, this attribute will be accessible via This.data.lastname.

Your template letter will therefore contain these kinds of expressions:

A function in the PeopleSelection class

For the beauty of the code, you can create a function that will receive the template printed with the entities’ data.

Class extends EntitySelection

Function mailing($template : Object)
For each ($people; This)
  WP SET DATA CONTEXT($template; $people)
  WP PRINT($template)
End for each 

The call of this function will be done as follows in an exquisite way:

// create entity selection
$es
:=ds.People.all()
// mailing based on 4D Write Pro template
$es
.
mailing($template) 

Conclusion

More information can be found in the documentation. And feel free to share with us your feedback and experience on the 4D forum.

Discuss

Tags 4D Write Pro, Data context, Entity selection, ORDA, v19 R5, v20, Word processor

Latest related posts

  • October 23, 2025

    Starting Qodly studio is just two clicks away

  • October 22, 2025

    Localize your Qodly Pages: A Practical Guide

  • October 21, 2025

    New Way to Control Your HTTP Responses

Roland Lannuzel
Roland Lannuzel
• Product Owner & 4D Expert • After studying electronics, Roland went into industrial IT as a developer and consultant, building solutions for customers with a variety of databases and technologies. In the late 80’s he fell in love with 4D and has used it in writing business applications that include accounting, billing and email systems.Eventually joining the company in 1997, Roland’s valuable contributions include designing specifications, testing tools, demos as well as training and speaking to the 4D community at many conferences. He continues to actively shape the future of 4D by defining new features and database development tools.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • AI
  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • 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 20 R10 21 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

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

© 2025 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