Add
is used to add a contact or contact group to a contacts database. If the contact or contact group already exists in the database, it is replaced with the new entry.
You can use this method to both add and edit contacts and contact groups. The data is added to the specified database. When no database is specified, the data is added to the default database. If the default database does not exist, Add
creates a new database. This method can be called both in synchronous and asynchronous mode.
The following is an example for using Add
:
Synchronous
contacts_handle.call('Add', {'Type': u'Contact', 'Data': {'FirstName': {'Label': u'first name', 'Value': u'Daniel'}, 'LastName': {'Label': u'last name', 'Value': u'Craig'}, 'MobilePhoneGen': {'Label': u'mobile', 'Value': u'9008025211'}, 'EmailHome': {'Label': u'email', 'Value': u'dcraig@ford.com'}}})
The following table summarizes the specification of Add
:
Interface | IDataSource |
Operation | Adds contact/group to the specified/default contacts database. |
Response Model | Synchronous and asynchronous for Third Edition FP2 and Fifth Edition devices. Synchronous for Third Edition and Third Edition FP1 devices. |
Pre-condition | IDataSource interface is loaded. For editing an existing contact/group, the specified Id must exist. You must use GetList to retrieve the Id for editing. |
Post-condition | Adds a new contact item to the database in case of add and updates an existing contact in case of edit. |
Input Parameters
Input parameter contains the contact information to add or edit and also the target database.
|
Output Parameters
The output contains ErrorCode
and an ErrorMessage
if the operation fails.
|
Errors
The following table lists the errors and their values:
|
Error Messages
The following table lists the error messages and their description:
|
Example
The following sample code illustrates how to add a contact information:
# Load contacts module contacts_handle = scriptext.load('Service.Contact', 'IDataSource') try: contacts_handle.call('Add', {'Type': u'Contact', 'Data': {'FirstName': {'Label': u'first name', 'Value': u'Daniel'}, 'LastName': {'Label': u'last name', 'Value': u'Craig'}, 'MobilePhoneGen': {'Label': u'mobile', 'Value': u'9008025211'}, 'EmailHome': {'Label': u'email', 'Value': u'dcraig@ford.com'}}}) print "Contact added Successfully" except scriptext.ScriptextError, err: print "Error adding the contact : ", err
See About this document... for information on suggesting changes.