# IDataSource.Organise()

Description:

The `Organise` method adds contacts to a contact group (association) or removes 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 both synchronously and asynchronously.

Syntax:

For synchronous calls:

    result = so.IDataSource.Organise(criteria);

For asynchronous calls:

    result = so.IDataSource.Organise(criteria, callback);

Arguments:

- `criteria`:

  This is an object that specifies which contact group to organize and how. For more information about the object properties and how to define them, see section Criteria for organizing contacts in a contact group.

- `callback`:

  The `callback` argument is the name of the method that is executed when an asynchronous `Organise` call has results or status information to return. You must define this method separately. Follow the instructions in section Defining the callback handler for an asynchronous method to define the `callback` method.

  This argument is used only with an asynchronous `Organise` call.

Return value:

If synchronous, the `Organise` method returns an object that contains an error code and an error message.

If asynchronous, the method returns an object that contains a transaction ID for the `callback` instance, an error code, and an error message. When the asynchronous call has completed, `callback` returns an object that contains an error code and an error message (see Table: Callback return value).

Table: Return value properties for Organise
Property | Description | Value
--- | --- | ---
`result.TransactionID` | This is a number used as an identification to match transactions started with an asynchronous `Organise` call to one or more calls it generates to `callback`. This property is only valid for asynchronous calls. |
`result.ErrorCode` | This is a number that specifies a predefined error code. | See Service API error codes.
`result.ErrorMessage` | This is a text string that describes the error. | See Contacts Service API error messages.

Remarks:

- The default contacts database is `cntdb://c:contacts.cdb`.

- `Organise` is not supported for SIM card databases, since contact groups cannot be created in a SIM card database.

Example code:

For the complete source of a sample widget that demonstrates how to use this Service API, see the full example.