|
|
|
date: Tue, 7 Oct 2008 21:31:00 -0700,
group: microsoft.public.crm.developer
back
Search for a particular set of entities using filter option
Hi,
I am using a filter option in a query to search for a particular entity.
If For e.g I have 10 account entities acc1, acc2, acc3,
ac4,ac5,acg6,acy7,acc,ac9,aco10.
I would like to query the CRM in such a way that, if I use filter option for
ac, it should return me all the 10 entities.
The code snippet is as follows:
ColumnSet col = new ColumnSet();
col.Attributes = new string[] {"accountid", "name", "statuscode",
"statecode" };
ConditionExpression condition = new ConditionExpression();
// Set the Condition for the Retrieval to be when the acount name starts
with ac
condition.Operator = ConditionOperator.Like;
condition.AttributeName = "name";
condition.Values = new string[] {"ac"};
// Set the Filter's Properties
FilterExpression filter = new FilterExpression();
filter.FilterOperator = LogicalOperator.And;
filter.Conditions = new ConditionExpression[] { condition };
QueryExpression query = new QueryExpression();
query.ColumnSet = col;
query.Criteria = filter;
query.EntityName =EntityName.account.ToString();
query.PageInfo = new PagingInfo();
query.PageInfo.Count = 1;
query.PageInfo.PageNumber = 1;
BusinessEntityCollection accounts = cService.RetrieveMultiple(query);
This code does not return me any entity. Can anyone suggest me how can I
modify the code or if there is any other way to use search in CRM. Thanks in
advance.
date: Tue, 7 Oct 2008 21:31:00 -0700
author: kavitha
Re: Search for a particular set of entities using filter option
Use a wildcard in the condition value, otherwise it does an exact
comparison:
condition.Operator = ConditionOperator.Like;
condition.AttributeName = "name";
condition.Values = new string[] {"ac%"};
(Note the % in "ac%")
--
Michael Höhne, Microsoft Dynamics CRM MVP
CRM Blog: http://www.stunnware.com/?area=blog
"kavitha" wrote in message
news:D241EB6E-7F83-42C0-9EF1-AAF7634F0B93@microsoft.com...
> Hi,
> I am using a filter option in a query to search for a particular entity.
> If For e.g I have 10 account entities acc1, acc2, acc3,
> ac4,ac5,acg6,acy7,acc,ac9,aco10.
> I would like to query the CRM in such a way that, if I use filter option
> for
> ac, it should return me all the 10 entities.
> The code snippet is as follows:
>
> ColumnSet col = new ColumnSet();
> col.Attributes = new string[] {"accountid", "name", "statuscode",
> "statecode" };
>
> ConditionExpression condition = new ConditionExpression();
>
> // Set the Condition for the Retrieval to be when the acount name starts
> with ac
> condition.Operator = ConditionOperator.Like;
> condition.AttributeName = "name";
> condition.Values = new string[] {"ac"};
>
> // Set the Filter's Properties
> FilterExpression filter = new FilterExpression();
> filter.FilterOperator = LogicalOperator.And;
> filter.Conditions = new ConditionExpression[] { condition };
>
> QueryExpression query = new QueryExpression();
> query.ColumnSet = col;
> query.Criteria = filter;
> query.EntityName =EntityName.account.ToString();
>
> query.PageInfo = new PagingInfo();
> query.PageInfo.Count = 1;
> query.PageInfo.PageNumber = 1;
>
> BusinessEntityCollection accounts = cService.RetrieveMultiple(query);
>
>
> This code does not return me any entity. Can anyone suggest me how can I
> modify the code or if there is any other way to use search in CRM. Thanks
> in
> advance.
date: Wed, 8 Oct 2008 08:50:58 +0200
author: Michael Höhne am
Re: Search for a particular set of entities using filter option
Thank you. It worked
"Michael Höhne" wrote:
> Use a wildcard in the condition value, otherwise it does an exact
> comparison:
>
> condition.Operator = ConditionOperator.Like;
> condition.AttributeName = "name";
> condition.Values = new string[] {"ac%"};
>
> (Note the % in "ac%")
>
> --
> Michael Höhne, Microsoft Dynamics CRM MVP
>
> CRM Blog: http://www.stunnware.com/?area=blog
>
> "kavitha" wrote in message
> news:D241EB6E-7F83-42C0-9EF1-AAF7634F0B93@microsoft.com...
> > Hi,
> > I am using a filter option in a query to search for a particular entity.
> > If For e.g I have 10 account entities acc1, acc2, acc3,
> > ac4,ac5,acg6,acy7,acc,ac9,aco10.
> > I would like to query the CRM in such a way that, if I use filter option
> > for
> > ac, it should return me all the 10 entities.
> > The code snippet is as follows:
> >
> > ColumnSet col = new ColumnSet();
> > col.Attributes = new string[] {"accountid", "name", "statuscode",
> > "statecode" };
> >
> > ConditionExpression condition = new ConditionExpression();
> >
> > // Set the Condition for the Retrieval to be when the acount name starts
> > with ac
> > condition.Operator = ConditionOperator.Like;
> > condition.AttributeName = "name";
> > condition.Values = new string[] {"ac"};
> >
> > // Set the Filter's Properties
> > FilterExpression filter = new FilterExpression();
> > filter.FilterOperator = LogicalOperator.And;
> > filter.Conditions = new ConditionExpression[] { condition };
> >
> > QueryExpression query = new QueryExpression();
> > query.ColumnSet = col;
> > query.Criteria = filter;
> > query.EntityName =EntityName.account.ToString();
> >
> > query.PageInfo = new PagingInfo();
> > query.PageInfo.Count = 1;
> > query.PageInfo.PageNumber = 1;
> >
> > BusinessEntityCollection accounts = cService.RetrieveMultiple(query);
> >
> >
> > This code does not return me any entity. Can anyone suggest me how can I
> > modify the code or if there is any other way to use search in CRM. Thanks
> > in
> > advance.
>
date: Tue, 7 Oct 2008 23:57:01 -0700
author: kavitha
|
|