Organise
is used to add contacts to a contact group (association) or remove contacts from a contact group (disassociation). The operation is performed on the specified database or, if no database is specified, on the default one.
This method can be called in both synchronous and asynchronous mode.
The following is an example for using Organise
:
Asynchronous
event_id = contacts_handle.call('Organise', {'Type': u'Group','Data': {'id': unicode(req_groupid[0]),'IdList': [req_id]}, 'OperationType': u'Associate'},callback=export_contact)
where, export_contact
is a user defined function.
The following table summarizes the specification of Organise
:
Interface | IDataSource |
Operation | Associates or disassociates a list of contacts in a database to and from a group. |
Response Model | Asynchronous and synchronous for Third Edition FP2 and Fifth Edition devices. Synchronous for Third Edition and Third Edition FP1 devices. |
Pre-condition | Valid IDataSource interface is loaded. The IDs specified for group and contact must exist and can be retrieved using GetList . |
Post-condition | Contacts from the default or specified contacts database are associated/ disassociated to and from a group. |
Input Parameters
Input parameter specifies which contact group to organize.
|
Output Parameters
The output is an object, which 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 associate or disassociate a contact from a group:
import scriptext import e32 # Using e32.Ao_lock() to make main function wait till callback is hit lock = e32.Ao_lock() req_groupid = [] # Callback function will be called when the requested service is complete def export_contact(trans_id, event_id, input_params): if event_id != scriptext.EventCompleted: # Check the event status print "Error in retrieving required info" print "Error code is: " + str(input_params["ReturnValue"]["ErrorCode"]) if "ErrorMessage" in input_params["ReturnValue"]: print "Error message:" + input_params["ReturnValue"]["ErrorMessage"] else: print "The contact is organised" lock.signal() # Load contacts module contacts_handle = scriptext.load("Service.Contact", "IDataSource") list_contacts = contacts_handle.call('GetList', {'Type': u'Contact', 'Filter': {'SearchVal': u'Clark'}}) for i in list_contacts: req_id = i['id'] list_groups = contacts_handle.call('GetList', {'Type': u'Group'}) for j in list_groups: req_groupid.append(j['id']) event_id = contacts_handle.call('Organise', {'Type': u'Group', 'Data': {'id': unicode(req_groupid[0]), 'IdList': [req_id]}, 'OperationType': u'Associate'}, callback=export_contact) print "Waiting for the request to be processed!" lock.wait() print "Request complete!"
See About this document... for information on suggesting changes.