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
COMPUTED ATTRIBUTES
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.zipCode:="78230" $Obj.city:="Le Pecq" $Obj.country:="France" $Obj.phoneNumber:="+33 1 30 53 92 00" $Obj.website:="fr.4d.com" $Ent:=ds.Employees.get(4) $Ent.Object_Attribute:=$Obj $Ent.save()
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!
SWIFT FORMATTERS
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!