4D for iOS gives you the ability to define actions that automatically call a 4D method linked with an event on the smartphone. For example, using them, you can execute 4D code, manage and edit your app’s content using parameters, and, more recently, sort your app’s content easily using sort actions!
Defining sort criteria and action parameters has been improved to make things easier and help you work more quickly and efficiently.
As you probably know, 4D for iOS offers various types of preset actions to ease your development process:
So what’s new?
Regarding the Sort action, you can now easily change action sort criteria using a simple dropbox. This enables you to choose another field among the available ones:
linking action parameters to FIELDS
For the Add… and Edit… preset actions, at the bottom of the Action Parameters panel, a message indicates when a parameter is linked to an existing field:
Why link action parameters to FIELDS?
As a reminder, the MobileAppServer component, which is built in 4D, gives you access to various utility methods to speed up your 4D mobile app backend coding.
In our case, it will allow you to get a dataClass or entity using generic code, and map parameters and fields generically. So there’s no need to write specific code anymore!
Here is an example of the On Mobile App Action that you can get using the Add preset action and the MobileAppServer component :
#DECLARE($request : Object)->$response : Object $action:=MobileAppServer.Action.new($request) $response:=New object("success"; False) Case of : ($action.name="addEmployees") // add@ var $entity; $status : Object $entity:=$action.newEntity() $status:=$entity.save() // save the entity If ($status.success) $response.success:=True // notify App that action success $response.dataSynchro:=True // notify App to refresh the selection $response.statusText:="Employee added" Else $response.statusText:="Failed to add" // $status.statusText $response.errors:=$status.errors End if End case
As a reminder, to add linked parameters to the field, click on the plus button arrow located at the bottom of the action parameter’s panel:
And you are still free to create parameters that do not have representation in your database, by clicking on the New parameter item from the menu.
Starting with v19 R3, you can edit and link/unlink an action parameter by changing its name: 4D for iOS detects automatically if the name of a parameter corresponds to an existing field name. And best of all, 4D for iOS helps with autocompletion and tells you which fields are available and linked with your parameter. Once it is linked, all the parameter properties are automatically adapted depending on the linked field type.
For those who were already using actions, all your logic is, of course, preserved.
This feature looks very simple, but I can fully guarantee that it will make your 4D for iOS app creation process much more pleasant!
Feel free to comment on the 4D forum, and check the dedicated documentation for more details.