The Anveo Mobile App provides the codeunit ACF App Events in Microsoft Dynamics NAV 2009R2 to which all incoming data changes are send from mobile devices during synchronization. In this codeunit, you can define what to do with data changes of mobile users. Detect and solve data conflicts here in case two users have changed same record due to offline capabilities. Furthermore, you can run individual C/AL code. This subsection describes its features.
The codeunit provides a large set of global variables. Depending of what function is run, the variables are set with values. Which variables are set, you can see in first comment line of each function.
This variable contains the record of Microsoft Dynamics NAV 2009R2 including all fields. It was retrieved from SQL database with GET(Primary Key) before. It is the one to be changed in this codeunit. RecRef is the most important variable you can use to set your changes – with or without modification of incoming data.
In this codeunit, you define what data should be transferred from mobile device stored in DeviceRecRef to your RecRef. Step-by-step you can set your values in RecRef until it is written back to your SQL database using INSERT or MODIFY later in the process.
Record of mobile device. It only contains data of fields that are included in Synchronization Packages for current user. This RecordRef is data source to set values in RecRef.
Previous record of mobile device. It only contains data of fields that are included in Synchronization Packages for current user. This RecordRef containts the data before the user or Anveo Script did changes on the mobile device.
This is very important to detect data conflicts: By comparing RecRef. and xDeviceRecRef you get the information if two persons have changed same data at the same time. In RecRef you get the current value of Microsoft Dynamics NAV 2009R2, in xDeviceRecRef you see the record before it was changed in the app. If they differ, the user might have decided to change values on old data.
For each table and field, you can decide whether you want to compare values of fields and what fields to include for comparing – some fields or all fields of the record.
This property gives you the information if a value was changed in the user interface or by Anveo Script.
Option values are: User, Script.
You can use this for field Sell-to Name in table Sales Header: A change done by Anveo Script must come from your mobile table trigger and can be ignored because C/AL code in Microsoft Dynamics NAV 2009R2 does the same. But changes in the user interface by the user are individual changes that must be accepted.
For INSERT, MODIFY and DELETE the value NAVAction defines whether to accept incoming data changes and whether to run table triggers OnInsert, OnModify or OnDelete in your Microsoft Dynamics NAV 2009R2 table. Furthermore, you can reject data changes on your mobile device and send an update package to the mobile device that rejects the change.
If you set a value to a field, this property decides if you want to accept the change and if you want to execute the VALIDATE function in Microsoft Dynamics NAV 2009R2.
Change of data is accepted and Microsoft Dynamics NAV 2009R2 runs its table trigger.
Change of data is accepted, but no table trigger will run in Microsoft Dynamics NAV 2009R2.
Change of data is not accepted, and no reject is sent to mobile device. In this case you have to take care about data consistency between Microsoft Dynamics NAV 2009R2 and the mobile device.
Change of data is not accepted, and a reject message is sent to the mobile device.
If you have received a deletion of a record, this will send a record-creation message to the mobile device. In case of a new record, a deletion message is sent. This ensures data consistency.
In function OnSetValue you can use property RemoteAction to see if a data change in Anveo Script was done by SETVALUE or VALIDATE . Changes of the user in the user interface are marked as VALIDATE.
For a better understanding of the processing of incoming data we recommend to activate a detailed text log. This is done by setting up Logging Level in Anveo User to (further info here). You will get a detailed step-by-step protocol of data processing.
This function is run before running the initialization and synchronization process. The parameter IsInit shows whether it is the first initialization or a synchronization.
A synchronization begins after all incoming data from mobile device was processed.
This function is run if the user changes a value in the user interface or Anveo Script uses the commands SETVALUE or VALIDATE. This function can be used to decide whether to accept or to ignore incoming value changes. The option NAVAction is used to decide whether to run table trigger OnValidate of that field.
This is function is run before a record will be inserted into Microsoft Dynamics NAV 2009R2 database. It is used by OnInsertRecord to structure code only.
This function is run if Anveo Script uses the command Record:INSERT(). The option NAVAction is used to decide whether to run RecRef.INSERT() and its table trigger OnInsert at the end of the function.
This function is run if the user has changed a value in the user interface or if Anveo Script used the command Record:MODIFY(). The option NAVAction is used to decide whether to run RecRef.MODIFY() and its table trigger OnModify at the end of the function.
This function is run if Anveo Script uses the command Record:DELETE(). The option NAVAction is used to decide whether to run RecRef.DELETE() and its table trigger OnDelete at the end of the function.
This function is responsible to save report results as a PDF document and sent it to the user using the ACF File Repository table.
This function is part of mobile number series management. It is responsible to transform RecRefs with mobile number series to final number series from Microsoft Dynamics NAV 2009R2.
For some languages it is required for the mobile device to transform the windows language of table Language into another windows language value.
These functions are used internally to set and get values from this codeunit.