{{tag>}} [<10>] ==== 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: getObjectData: function (objectName, objectId, callBackFunction) ''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 AwareIM operation of the "Execute Script" type AwareIM 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''; and to get object id we use ''context[0].objectId'' So the Javasrcipt we need to write to create a contact looks like this: AwareApp.getObjectData ( context[0].objectName, context[0].objectId, function (objectData) { navigator.contacts.create ({ "displayName": objectData["FirstName"] + " " + objectData["LastName"], "birthday": kendo.parseDate (objectData["DateOfBirth"], "dd/MM/yyyy", "en-US") }); } ); 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", "LastName" and "DateOfBirth" are the names of the attributes of the Customer object in the CRM application. Note also that all AwareIM attribute values are strings and if the plugin requires some other type (for example, date), then the strings need to be converted to the appropriate type. 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. {{simplenavi>docs:3500:0800:0890:0891:}}