This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v19.8
On Mobile App Action database method

On Mobile App Action database method 


 

$1 -> On Mobile App Action database method -> $0 
Parameter Type   Description
$1  Object in Information passed by the mobile application
$0  Object in Action status & data synchro

The On Mobile App Action database method is in charge of managing actions requested by the mobile application for a specific session.  

Note: The mobile application must have been authenticated by the On Mobile App Authentication database method

This database method is called by 4D when a mobile application sends an action request. 

Note: For more information, please refer to the 4D for iOS documentation

The database method receives required information from the mobile application in the $1 parameter (object), and must return the action status in the $0 parameter (object). You must declare and initialize these parameters as follows:

  //On Mobile App Action database method
 C_OBJECT($0;$1)
  // ...Code for the method
 $0:=New object //do not forget to create the object to return

The following properties are received in the $1 object parameter:

Property nameTypeDescription
actionTextAction name
sessionObjectSession information
idTextSession identifier
ipTextSession IP
applicationObjectMobile application information
idTextApplication id
userInfoTextUser information
contextObjectContext parameters for the requested action
dataClassText4D dataclass name
entity.primaryKeyText | Longint(optional, returned if the action is related to a selected entity)
Primary key of the entity. 
entity.relationNameText(optional, returned if the action is related to a linked entity)
Many-to-one relation name
parent.primaryKeyText | Longint(optional, returned if the action is related to a linked entity)
Primary key of the parent entity.
parent.relationNameText(optional, returned if the action is related to a linked entity)
One-to-many relation name
parent.dataClassText(optional, returned if the action is related to a linked entity)
Name of the parent 4D dataclass.

After processing information, the database method must return an object with the following properties in $0:

Property nameTypeDescription
successBooleanTrue if action has been successfully processed, False otherwise.
statusTextText(Optional) Message to display on the mobile application. If success=true, display message; if success=false, can be used to provide user with an explanation
dataSynchroBooleanTrue if the entity or table selection needs to be refreshed, false otherwise. If True, the mobile application will automatically trigger a data synchronization

Example  

  // On Mobile App Action
  // 2 actions are defined: "done" and "postponeAll"
 
 C_OBJECT($0)
 C_OBJECT($1)
 
 C_OBJECT($o;$context;$request;$result)
 
 $request:=$1 //Information provided by the mobile app
 $context:=$request.context
 
 Case of
 
    :($request.action="done")
       $o:=New object(\
       "dataClass";$context.dataClass;\
       "ID";$context.entity.primaryKey;\
       "CompletePercentage";100)
 
       $result:=modifyStatus($o//call your project method to modify the status of the entity
 
    :($request.action="postponeAll")
       $o:=New object("dataClass";$context.dataClass)
 
       $result:=postponeAll($o//call your project method to postpone all entities of the dataClass
 
    Else //Unknown request
       $result:=New object("success";False)
 
 End case
 
 $0:=$result  //Information returned to mobile app



See also 

On Mobile App Authentication database method

 
PROPERTIES 

Product: 4D
Theme: Database Methods

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v17 R5

 
ARTICLE USAGE

4D Language Reference ( 4D v19)
4D Language Reference ( 4D v19.1)
4D Language Reference ( 4D v19.4)
4D Language Reference ( 4D v19.5)
4D Language Reference ( 4D v19.6)
4D Language Reference ( 4D v19.7)
4D Language Reference ( 4D v19.8)