Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| docs:3500:0800 [2023/04/05 05:44] – [Modifying default behavior and presentation of content panels in visual perspectives] sean | docs:3500:0800 [2025/06/12 02:36] (current) – Rename to AwareIM aware_support3 | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| ====== Writing client-side plugins ====== | ====== Writing client-side plugins ====== | ||
| - | In //**Aware IM**// you can not only add plugins for the server (such as custom processes, channels or functions), but you can also add plugins that execute on the client within a web browser. Most of the time you would write these plugins in order to add your custom user interface functionality, | + | In //**AwareIM**// you can not only add plugins for the server (such as custom processes, channels or functions), but you can also add plugins that execute on the client within a web browser. Most of the time you would write these plugins in order to add your custom user interface functionality, |
| All client-side plugins must be written in Javascript and in most cases you need the knowledge of the [[http:// | All client-side plugins must be written in Javascript and in most cases you need the knowledge of the [[http:// | ||
| - | There are several types of the client-side plugins you can add in //**Aware IM**//: | + | There are several types of the client-side plugins you can add in //**AwareIM**//: |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| We will look at each of these client-side plugins separately | We will look at each of these client-side plugins separately | ||
| - | + | {{simplenavi> | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | ===== AwareApp object ===== | + | |
| - | + | ||
| - | When writing advanced scripts as described above you can use the AwareApp Javascript object that contains some useful static methods. This is an example of calling one of these methods: | + | |
| - | + | ||
| - | var panelId = AwareApp.getPanelId (“main”, | + | |
| - | + | ||
| - | The code of the object is located here: AwareIM/ | + | |
| - | + | ||
| - | The following methods can be used: | + | |
| - | + | ||
| - | - getPanelId (frameName, tabName, contentPanelName) | + | |
| - | This method returns the unique id of the content panel in a visual perspective. | + | |
| - | + | ||
| - | var id = AwareApp.getPanelId (‘main’, | + | |
| - | + | ||
| - | Parameters: | + | |
| - | + | ||
| - | frameName – name of the frame in the visual perspective that contains the panel | + | |
| - | + | ||
| - | tabName – name of the tab inside the frame that contains the panel | + | |
| - | + | ||
| - | contentPanelName – name of the content panel | + | |
| - | + | ||
| - | - getFramePanelId (frameName) | + | |
| - | This method returns the unique id of the frame in a visual perspective. | + | |
| - | + | ||
| - | var id = AwareApp.getFramePanelId (‘main’); | + | |
| - | + | ||
| - | Parameters: | + | |
| - | + | ||
| - | frameName – name of the frame in the visual perspective | + | |
| - | + | ||
| - | - getTabPanelId (frameName, tabName) | + | |
| - | This method returns the unique | + | |
| - | + | ||
| - | var id = AwareApp.getTabPanelId (‘main’, | + | |
| - | + | ||
| - | Parameters: | + | |
| - | + | ||
| - | frameName – name of the frame in the visual perspective that contains the panel | + | |
| - | + | ||
| - | tabName – name of the tab inside the frame that contains the panel | + | |
| - | + | ||
| - | - isRTL () | + | |
| - | Return true if the current user uses right-to-left layout | + | |
| - | + | ||
| - | - getMainTabPanel () | + | |
| - | If a visual perspective has tabs return the tab panel holding the tabs. | + | |
| - | + | ||
| - | - getProcessId () | + | |
| - | Return the id of the currently running process or -1 if there are no processes currently running. | + | |
| - | + | ||
| - | - isTestingMode () | + | |
| - | Return true if the current user is running in the testing mode | + | |
| - | + | ||
| - | - startProcess, | + | |
| - | Please refer to the “Links to Aware IM operations” section in the User Guide, that explains how to set up links to perform operations. All functions mentioned there can be used from your Javascript. | + | |
| - | + | ||
| - | ===== Using Javascript to integrate custom Cordova plugins for native mobile applications ===== | + | |
| - | + | ||
| - | Cordova plugins are components that provide access to some built-in features of mobile phones, (such as camera or contacts), for which there is no Javascript access. When components are integrated into the system these features become available through some special Javascript functions that the plugin makes available to the developer. Cordova plugins can only be used in native mobile applications. | + | |
| - | + | ||
| - | Aware IM integrates some Cordova plugins out-of- the-box and provides rule actions that activate them (for example, MOBILE PUSH or MOBILE CAMERA SNAP INTO. However, there are many plugins around and it is impossible to integrate all of them into Aware IM. | + | |
| - | + | ||
| - | Still there is a way to do this by adding some custom Javascript to your application. The following section explains how to do it. | + | |
| - | + | ||
| - | This is the high level overview of what needs to be done: | + | |
| - | + | ||
| - | - Study the documentation of the Cordova plugin to fully understand Javascript methods that it exposes | + | |
| - | - Write the Javascript that calls the appropriate Javascript function that the plugin provides | + | |
| - | - Give this function the data obtained from Aware IM if necessary. For example, read the data from the database and provide this data to the function of the plugin. The useful Aware IM function that can be used here is AwareApp.getObjectData() | + | |
| - | - Handle the return of this function if necessary – for example write the data returned by the function to the database. Useful Aware IM functions for this are AwareApp.createOrUpdateObject() and AwareApp.startProcessWithInit() | + | |
| - | - Define panel operations or menu items in the mobile part of your business space version (using the Configuration Tool) that would run this Javascript. You should select an operation or menu item of the “Execute Javascript” type for this. | + | |
| - | - Build a native mobile application for your business space version using the “Build Native Mobile Application” command in the Configuration Tool. This will create a zip file. | + | |
| - | - Uzip this zip file somewhere. Find the config.xml file in the root of the unzipped application and open it for editing. | + | |
| - | - Find the section in this file that lists the plugins used by the application, | + | |
| - | <plugin name=" | + | |
| - | + | ||
| - | Add the definition of the Cordova plugin you need to integrate – look up the documentation of the plugin for details of the plugin name and version number | + | |
| - | + | ||
| - | - Zip up the application again and use the PhoneGap build to create application files in the native format of the mobile phone | + | |
| - | Let’s look at an example. We will be integrating a Cordova plugin for Contacts into the CRM mobile sample application. | + | |
| - | + | ||
| - | The documentation of the plugin can be found here: [[https:// | + | |
| - | + | ||
| - | As we can see the plugin provides the navigator.contacts object that can be used to create contacts, find existing contact or pick a particular one. Let’s add the following functionality to the CRM application: | + | |
| - | + | ||
| - | - From the form of a customer or from a customer list create a phone contact populated with the information from the customer record in the application | + | |
| - | - Pick a contact from the list of phone contacts and send this contact an email that includes some information stored in the application | + | |
| - | ==== Creating a contact on the phone ==== | + | |
| - | + | ||
| - | We need to use the “create” method of the navigator.contacts object and provide contact data available in the customer record that we are parked on. Retrieving the data can be done using the AwareApp.getObjectData function. It has the following signature: | + | |
| - | + | ||
| - | | + | |
| - | + | ||
| - | ObjectName and objectId identify the record to retrieve and callBackFunction specifies a function that will be called when the data has been retrieved. The function will be called with the object storing the retrieved values. | + | |
| - | + | ||
| - | How do we get object name and id? When we define an Aware IM operation of the “Execute Script” type Aware IM automatically defines the following objects that we can use in our Javascript: | + | |
| - | + | ||
| - | - parser | + | |
| - | - context | + | |
| - | The parser object should be already familiar and the context object stores an array of objects with objectName and objectId attributes. The record we are parked on is the first and only one in this array. So to get objectName we use the following context[0].objectName; | + | |
| - | + | ||
| - | So the Javasrcipt we need to write to create a contact looks like this: | + | |
| - | + | ||
| - | AwareApp.getObjectData ( | + | |
| - | + | ||
| - | | + | |
| - | + | ||
| - | | + | |
| - | + | ||
| - | | + | |
| - | + | ||
| - | { | + | |
| - | + | ||
| - | | + | |
| - | + | ||
| - | | + | |
| - | + | ||
| - | | + | |
| - | + | ||
| - | }); | + | |
| - | + | ||
| - | } | + | |
| - | + | ||
| - | ); | + | |
| - | + | ||
| - | Note that here “displayName” and “birthday” are the names of the attribute of the Contact object on the phone exposed by the plugin, whereas “FirstName”, | + | |
| - | + | ||
| - | The next step is to create operations of the “Execute Script” type to the form and customer list. We can add a panel operation to the “Editing Mobile” form of the Customer object and an operation with record to the “Customer – all mobile” query. We then specify the above script as a parameter of the operation. | + | |
| - | + | ||
| - | ==== Send email to the selected contact ==== | + | |
| - | + | ||
| - | We need to use the pickContact method of the navigator.contacts object to display a list of contacts, let the user pick one and then we need to start a process in the application to send an email to the email address of the contact picked by the user. | + | |
| - | + | ||
| - | The email address returned by the plugin needs to be saved in some temporary object and then this object can be used in the process. So we will create a temporary business object (persistence type – memory) called ContactParam with the single EmailAddress attribute. We will then create a process called SendEmailToContact with the ContactParam object as its input. The process will then use the SEND action to send any email to this email address (the email can use tag expressions to retrieve some information from the system – for example, from SystemSettings or from the logged in user). | + | |
| - | + | ||
| - | To start a process we will use the AwareApp.startProcessWithInit function. It has the following signature: | + | |
| - | + | ||
| - | startProcessWithInit: | + | |
| - | + | ||
| - | Here procName is the name of the process to start, renderOption is where to display the results of the process (we can use null), objName is the name of the parameter object, initValues is the object storing values of the parameter object and context contains additional parameter objects (null in our case) | + | |
| - | + | ||
| - | So our Javascript can look like this: | + | |
| - | + | ||
| - | navigator.contacts.pickContact (function (contact) | + | |
| - | + | ||
| - | { | + | |
| - | + | ||
| - | var email = contact.emals[0].value; | + | |
| - | + | ||
| - | | + | |
| - | + | ||
| - | | + | |
| - | + | ||
| - | null, | + | |
| - | + | ||
| - | | + | |
| - | + | ||
| - | { “EmailAddress” : email } | + | |
| - | + | ||
| - | }, | + | |
| - | + | ||
| - | function (error { console.log (error); | + | |
| - | + | ||
| - | ); | + | |
| - | + | ||
| - | Then we just need to add a command of the “Execute Script” type to the mobile menu of the application. | + | |
| - | + | ||
| - | + | ||