Microsoft CRM 3.0 .Net Query Expression help

Hi there,
I am developing a CRM 3.0 Callout in that uses a service.retrievemultiple statement that will retrieve the list of CRM 3.0 system users who own the contacts that a marketing campaign email or letter has been sent to.

I am after some assistance with the query expression, I have created what i think is the correct Advanced Find in the CRM interface as a sanity check that the general concept works but translating this into the query expression has me a little lost.

The Advanced find for the query would be as follows:
Look For: Users
Contacts (owners)
     Activity Parties(party)
                     Subject   Equals    XXXXX(Search Term)XXXXX

Is there anyone who knows enough to translate this search into a retirevemultiple query or could point me in the right direction?

Who is Participating?
rakeshAgarwalConnect With a Mentor Commented:

 You have to use concept of link entity  here. I am pasting code snippet from one of  SDK codes provided by microsoft

                        // Create the ConditionExpression.
                        ConditionExpression condition = new ConditionExpression();

                        // Set the condition for the retrieval to be when the last name of the account's owner is not Cannon.
                        condition.AttributeName = "partyid";
                        condition.Operator = ConditionOperator.Equal;
                        condition.Values = new string [] {user.UserId.ToString()};

                        // Build the filter based on the condition.
                        FilterExpression filter = new FilterExpression();
                        filter.FilterOperator = LogicalOperator.And;
                        filter.Conditions = new ConditionExpression[] {condition};

LinkEntity link = new LinkEntity();

                        // Set the properties of the LinkEntity.
                        link.LinkCriteria = filter;

                        // Set the linking entity to be the activity.
                        link.LinkFromEntityName = EntityName.activitypointer.ToString();

                        // Set the attribute being linked to to be the activityid.
                        link.LinkFromAttributeName = "activityid";

                        // Set the entity being linked to to be the activityparty.
                        link.LinkToEntityName = EntityName.activityparty.ToString();
                        // Set the attribute linking to the activityparty to be the activityid.
                        link.LinkToAttributeName = "activityid";
                        // Create the query.
                        QueryExpression query = new QueryExpression();

                        // Set the properties of the query.
                        query.EntityName = EntityName.activitypointer.ToString();
                        query.ColumnSet = new AllColumns();
                        query.LinkEntities = new LinkEntity[] {link};

 I think there is a tool in

Rakesh Agarwal  

r0t0ruaAuthor Commented:
Thanks for the SDK snippet, I already had the sample code as my base.  The real gem you supplied was the link which lead me to the FetchXML tool he has developed that generates the .Net query from a very easy to use GUI
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.