4D Blog

Home Product ORDA – Share an entity selection between processes

ORDA – Share an entity selection between processes

October 27, 2020

Product

4D v16 R6 introduced a new concept of communication between processes: shared object and shared collection variables! Thanks to this, you’re able to easily share information between processes.

Until now, entity selections weren’t shareable between processes. However, that has changed … we’re pleased to announce that in 4D v18 R5 entity selections are shareable! 

Gone are the days of building a list of primary keys to move a selection of entities to another process. Enhance your multi-processes code by including ORDA entity selections as shared objects.

Keep reading to learn more.

HDI: Share ORDA entity selections

 

principle

With 4D v18 R5, most entity selections are shareable. This means:

  • they are non-alterable (does not allow the addition of new entities).
  • they can be shared between several processes or workers.

 

Some entity selections are non-shareable (for example, if they’ve been created with dataClass.newSelection() or Create entity selection()). This means:

  • they are alterable (allows the addition of new entities)
  • they can’t be shared between several processes

 

shareable entity selections

Starting with 4D v18 R5, most used entity selections (retrieved with query(), all(), …) are shareable.

Let’s take a look at an example to better understand.

Example

In the example below, we build two entity selections:

  • one for paid invoices.
  • one for unpaid invoices.

 

We might want to pass them to a worker  to delegate sending:

  • acknowledgment emails for paid invoices.
  • reminder emails for unpaid invoices.

 

Here’s the code:

If (Storage.info=Null)
 Use (Storage)
  Storage.info:=New shared object()
 End use
End if

Use (Storage.info)
 //Put entity selections in a shared object
 Storage.info.paid:=ds.Invoices.query("status=:1"; "Paid")
 Storage.info.unpaid:=ds.Invoices.query("status=:1"; "Unpaid")
End use

CALL WORKER("mailing"; "sendMails"; Storage.info)

Here’s the sendMails method:

var $info; $1 : Object
var $paid; $unpaid : cs.InvoicesSelection
var $invoice : cs.InvoicesEntity
var $server; $transporter; $email; $status : Object

//Prepare emailss
$server:=New object
$server.host:="exchange.company.com"
$server.user:="myName@company.com"
$server.password:="my password"

$transporter:=SMTP New transporter($server)

$email:=New object
$email.from:="myName@company.com"

//Get entity selections
$info:=$1
$paid:=$info.paid
$unpaid:=$info.unpaid

//Loops on entity selections
For each ($invoice; $paid)
  $email.to:=$invoice.customer.address // email address of the customer
  $email.subject:="Payment OK for invoice # "+String($invoice.number)
  $status:=$transporter.send($email)
End for each

For each ($invoice; $unpaid)
  $email.to:=$invoice.customer.address // email address of the customer
  $email.subject:="Please pay invoice # "+String($invoice.number)
  $status:=$transporter.send($email)
End for each

As you can see, the worker can deal with the entity selections!

going back and forth between shareable / non shareable entity selections

In some cases, you might have a non shareable entity selection. If you need to share it with another process, just use the new .copy() class function available on entity selection objects.

Here’s an example of just that:

The Form.products is a new empty entity selection got with the newSelection() class function. Thus, it is not shareable and accepts adding an entity.

Form.products:=ds.Products.newSelection()

//Form.product is entered by the user
Form.products.add(Form.product)

If you try to put it “as is” in the $sharedObj shared object, you’ll get an error:

var $sharedObj : Object
$sharedObj:=New shared object()

Use ($sharedObj)
//Error "Not supported value type in a shared object or a shared collection"
$sharedObj.products:=Form.products
End use

Since ORDA thinks about everything, there’s a new .copy() class function available on entity selection objects.

It returns a copy of the given entity selection, so we can ask this copy to be shareable or not.

var $sharedObj : Object
$sharedObj:=New shared object()

Use ($sharedObj)
//Returns a shareable copy of the Form.products entity selection
$sharedObj.products:=Form.products.copy(ck shared)
End use

That’s it!

Of course with this new class function, you can also turn a shareable entity selection into a non shareable one by omitting the optional parameter.

Note the OB Copy command has been also updated:

  • it accepts an entity selection as parameter.
  • entity selections nested in the object to copy are also copied according to the passed option.

 

Download the HDI and check the documentation to learn more!

Discuss

Tags ORDA, Preemptive, Shareable, Shareable entity selection, Shared object, Storage, v18 R5

Latest related posts

  • December 3, 2025

    Give AI to a 30 years old 4D application

  • November 28, 2025

    ORDA – Handle an event-driven logic during database operations

  • November 27, 2025

    ORDA – Permissions – Restrict / allow web access to the resources in one click

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

  • 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