Passing data back and forth between forms

Wouldn’t it be great if you could just open a form and pass it some parameters to initialize your form objects? What about being able to also get the data back to process, after it’s been modified by the user? 4D v16 R5 makes your coding so much easier by greatly simplifying communications with forms.

Until now, when you wanted to display data (not coming from the database itself, but computed or external) to multiple users, you had two options: either write complex code to handle data display in multiple processes, or create as many forms as necessary with a bunch of global variables. But you know that global variables are not an optimized way of coding, from a memory point of view.

So get rid of your complex code and global variables! With 4D v16 R5 you can just bind an object to your form and use it internally with the new Form command. Painless…and powerful!

Example Database

Pass parameters to a form

It’s now possible to pass parameters in an object to a form using the DIALOG command. Any property of this object will then be available from within the form context via the Form command.

$address:=New object
$window:=Open form window("AddressForm";Movable form dialog box)
// The form is opened with the $address object in parameter
// This allows modifying the $address object in the form with the Form command
ALERT("New company name is:"+$address.CompanyName)

In the “AddressForm” form, you just need to use the Form command in the form object data source:

When the users close the dialog, the values they entered are available in the calling method via the $address object.

Pass parameters to a subform

In the same way that you pass an object to a form with the DIALOG command, you can also pass an object to a subform area using the property list. Then, you can use it in the subform with the Form command. In the example below, the InvoiceAddress object is bound to the subform.


Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.