Friday, 2 February 2018

QueryExpression to filter based on related entities in Dynamic CRM.

Sample: Retrieve multiple with the QueryExpression class

Description:

In this example we explain that how to filter the record based on QueryExpression in Dynamic CRM.or QueryExpression to filter based on related entities in Dynamic CRM.or retrieve the related entity records along with primary entity using Retrieve method in Dynamic CRM.

So here we demonstrate that Query Expression filter or condition against two linked entities in Dynamic CRM.or sample to retrieve multiple with the Query Expression class in Dynamic CRM.or Querying Data with the Query Expression in Dynamic CRM.

Here in below example we filter the contact entity with the Email Address and full name two conditional expression using Query Expression and return the related record if the match.
Code:

  ClientCredentials Credentials = new ClientCredentials();

             Uri OrganizationUri = new Uri("http://<SERVERURL>/<ORGNAME>/XRMServices/2011/Organization.svc");
            Uri HomeRealmUri = null;
            OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(OrganizationUri, HomeRealmUri, Credentials, null);
            IOrganizationService service = (IOrganizationService)serviceProxy;
            QueryExpression ContactlList = new QueryExpression("contact");
            ContactlList.ColumnSet = new ColumnSet(true);
            ContactlList.Criteria.AddCondition(

              "emailaddress1",
               ConditionOperator.Equal,
               txtEmailAddress.Text
           );
            ContactlList.Criteria.AddCondition(

             "fullname",
              ConditionOperator.Equal,
              txtFirstName.Text + " " + txtLastName.Text
          );

            var contactDetail = service.RetrieveMultiple(ContactlList);


This entry was posted in :

0 comments:

Post a Comment