4D for Mobile: Use Object Attributes

As of now, you can use almost all types of attributes in your mobile projects: text, dates, time, integers… 4D v19 R4 is bringing another one.

Say hello to object attributes.

Project editor side

As soon as you have object attributes in your 4D structure, you can publish them from the Structure section.

You can define an Icon, Short and Long labels, or formats just like any other attributes from the Labels and Icons section.

Two formats are already available to display your object attributes :

  • Human readable: default format, displays human-readable structured data in your mobile app
  • JSON Pretty Print: displays an indented JSON in your mobile app

Then you only have to drop your fields in your list or detail forms from the Forms section to display them in the generated mobile apps:

Mobile app side

As you can see, your object attributes are well displayed on iOS and Android:



Go further

 You are totally free to customize and adapt the mobile display to suit your needs. To do so, you can use two methods:

  • Computed attributes, to create the required format server-side
  • Swift formatters, to display only the values you need a client-side


In the following example, we want to display an address getting only relevant values that are available in the next object using computed attributes:

$Obj:=New object 
$Obj.name:="4D SAS" 
$Obj.address1:="66 rue de Sartrouville" 
$Obj.address2:="Parc les Erables, bâtiment 4" 
$Obj.city:="Le Pecq" 
$Obj.phoneNumber:="+33 1 30 53 92 00" 


For that, let’s extend the EmployeesEntity class:

Class extends Entity
exposed Function get fullAddress->$result : Text
 $result:=This.Address.name+" - "+This.Address.address1+" - "+This.Address.zipCode+" "+This.Address.city

As simple as that! 


Using a swift formatter will allow you to get more amplitude to display your object attributes in the way you want, putting your text in bold or adding styles and colors, for example. A tutorial is available here to build your first Swift formatter!

Don’t hesitate to give us feedback on the 4D forum, and check out the documentation for more details!

David Azancot
• 4D for iOS Product Owner •David Azancot joined the 4D Product team as a Product Owner in 2017. He's in charge of writing the user stories and translating them into functional specifications. His role also includes making sure that feature implementations meet customers' needs.David graduated with an MBA in Marketing, Internet and Mobility from the Leonard De Vinci Institute and began his career in 2011 with a mobile start-up company, later acquired by Madvertise (a mobile marketing group). Passionate about mobile interfaces, he was the natural choice to develop interactive mobile ad formats for the group in 2015. In parallel, David has been developing his own iOS and Android applications since 2012.