AquaLogic Interaction Development Kit (IDK) 6.0.0 |

# IDiscussionManager.QueryDiscussionMessages Method (IProject, IDiscussionMessageFilter)

Returns an array of `IDiscussionMessage`s the represent zero or more discussion messages in a given project, satisfying the discussion message filter criteria provided.

IDiscussionMessage[] QueryDiscussionMessages(
IProject project,
IDiscussionMessageFilter filter
);

#### Parameters

project
  The project to query discussion messages; cannot be `null`.
filter
  The discussion message query filter; cannot be `null`.

#### Return Value

An array of `IDiscussionMessage` containing zero or more discussion messages in a given discussion, satisfying the discussion message filter criteria provided.

#### Remarks

The following sample code shows how to query for discussion messages in a project.

    IDiscussionMessageFilter messageFilter = discussionManager.CreateDiscussionMessageFilter();

    //search for ALL messages; other options include searching for APPROVED, or UNAPPROVED messages
    messageFilter.MessageStatusType = DiscussionMessageStatusFilterTypes.All;

    //limit the return results to be 10; setting this to 0 will return all results
    messageFilter.MaximumResults = 10;

    //disable security checking on the returned objects against the user who performs this query,
    //so that all objects will be returned
    messageFilter.RestoreSecurity = false;

    //user DiscussionMessageQueryOrder to sort the query result; below DiscussionMessageQueryOrder
    //shows sorting the returned messages by CREATED date in descending order
    DiscussionMessageQueryOrder messageQueryOrder = new DiscussionMessageQueryOrder(DiscussionMessageAttributes.Created, false);
    messageFilter.setQueryOrders(new DiscussionMessageQueryOrder[] { messageQueryOrder });

    //an array of IDiscussionMessage objects are returned from queryDiscussionMessages(); if no result is retrieved, a zero-length array will be returned
    IDiscussionMessage[] retrievedMessages = discussionManager.QueryDiscussionMessages(project, messageFilter);

#### Exceptions

Exception Type | Condition
--- | ---
InvalidOperationException | The project has not yet been stored or has already been removed.
CollaborationException | The method call resulted in an error.
SoapException | There was a communication problem during the execution of the remote method call.

#### See Also

IDiscussionManager Interface | Plumtree.Remote.PRC.Collaboration.Discussion Namespace | IDiscussionManager.QueryDiscussionMessages Overload List