locked
Increasing the number of items returned in a lookup field RRS feed

  • Question

  • When I enter the first few characters in a CRM Look up field, it shows me a list of matching entries. This list is however limited to only 12 entries. Is there any way to increase the number of items returned on this list?
    Wednesday, September 1, 2010 8:32 AM

Answers

  • It seems really hard coded...

    If looking into CRM dll's:

     

    AppGrid grid = this.CreateLookupGrid(num2, lookupClass, bindingColumns, additionalParameters, value);

    EntityMetadata metadata2 = instance.GetEntity(num2);

    grid.DataProvider.SortColumns = grid.SortColumns;

    grid.DataProvider.AddParameters(grid.Parameters);

    grid.DataProvider.RecordsPerPage = 11;

    grid.DataProvider.PageNumber = 1;

    grid.DataProvider.Execute();

    grid.DataProvider.Reset();

     


    My blog : http://mscrmtools.blogspot.com

    All my tools on my new dedicated site: MSCRMTools Repository
    • Marked as answer by ysivaram Friday, September 3, 2010 3:42 AM
    Wednesday, September 1, 2010 9:42 AM
    Moderator
  • Hello.

    I checked and it really doesn't work. So it seems that there no easy and supported way to increase the number of lines returned by resolving-feature of lookup.


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    • Marked as answer by Jim Glass Jr Thursday, September 2, 2010 10:22 PM
    • Unmarked as answer by ysivaram Thursday, September 2, 2010 11:22 PM
    • Marked as answer by ysivaram Friday, September 3, 2010 3:42 AM
    Thursday, September 2, 2010 7:01 PM
    Moderator

All replies

  • I suppose you have only 12 matching record, so that you are getting only 12 records

    Also you can increase number of records that ms crm view returns from Workplace->Personalize Workspace.


    Mahain : http://mahenderpal.wordpress.com
    • Marked as answer by Jim Glass Jr Thursday, September 2, 2010 10:21 PM
    • Unmarked as answer by ysivaram Thursday, September 2, 2010 11:22 PM
    Wednesday, September 1, 2010 8:40 AM
    Moderator
  • When I enter the first few characters in a CRM Look up field, it shows me a list of matching entries. This list is however limited to only 12 entries. Is there any way to increase the number of items returned on this list?

    I don't think that this is possible without additional coding. What you can try - is to develop plugin which will handle Execute message, check HttpContext and in the case this call is made from lookup - increase the record per page limit (it seems that there is hard-coded 12). But I can't give you any guarantees that this will work.

    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    • Proposed as answer by Andrii ButenkoMVP, Moderator Wednesday, September 1, 2010 8:57 AM
    • Unproposed as answer by ysivaram Wednesday, September 1, 2010 9:15 AM
    • Marked as answer by Jim Glass Jr Thursday, September 2, 2010 10:21 PM
    • Unmarked as answer by ysivaram Thursday, September 2, 2010 11:22 PM
    Wednesday, September 1, 2010 8:46 AM
    Moderator
  • Mahendar:

    Thanks for your quick reply. However

    >>I suppose you have only 12 matching record, so that you are getting only 12 records

    I have more than 12 records.

    >>Also you can increase number of records that ms crm view returns from Workplace->Personalize Workspace.

    This only applies for records shown in a page. Not for the matches shown on lookup field.

     

    Furthermore as you can see from the following query, the LookupService RetrieveItem method sends the number of entries as twelve (top 12)

    exec

     

    sp_executesql N'select top 12 contact0.FullName as ''fullname'', contact0.ParentCustomerId as ''parentcustomerid'', contact0.Address1_City as ''address1_city'', contact0.Address1_Telephone1 as ''address1_telephone1'', contact0.Telephone1 as ''telephone1'', contact0.EMailAddress1 as ''emailaddress1'', contact0.ContactId as ''contactid'', contact0.Fax as ''fax'', contact0.Address1_Name as ''address1_name'', contact0.Address1_Fax as ''address1_fax'', contact0.ParentCustomerIdYomiName as ''parentcustomeridyominame'', contact0.ParentCustomerIdName as ''parentcustomeridname'', contact0.ParentCustomerIdType as ''parentcustomeridtype'', contact0.ParentCustomerIdDsc as ''parentcustomeriddsc'' from Contact as contact0 where ((contact0.DeletionStateCode in (@DeletionStateCode0)) and (contact0.LastName like @LastName0 or contact0.FirstName like @FirstName0 or contact0.EMailAddress1 like @EMailAddress10 or contact0.ParentCustomerIdName like @ParentCustomerIdName0) and (contact0.StateCode = @StateCode0)) order by contact0.FullName asc, contact0.ContactId asc',N'@DeletionStateCode0 int,@LastName0 nvarchar(5),@FirstName0 nvarchar(5),@EMailAddress10 nvarchar(5),@ParentCustomerIdName0 nvarchar(5),@StateCode0 int',@DeletionStateCode0=0,@LastName0=N'phil%',@FirstName0=N'phil%',@EMailAddress10=N'phil%',@ParentCustomerIdName0=N'phil%',@StateCode0=0

    Wednesday, September 1, 2010 8:48 AM
  • Andriy:

    The Lookup field is using a webservice call, which I think as you have mentioned may be hardcoding(?!) the number of records to 12. Can you please give me some quick pointers on how I can change this behaviour?

    Wednesday, September 1, 2010 8:53 AM
  • I developed plugin which handles Execute message. In your case you should develop similar plugin and change the count of records per page. Following article can help you:

    http://a33ik.blogspot.com/2009/09/overriding-records-per-page-count-for.html

    I meant that 12 is hard-coded to lookup-resolving engine as a record-per-page count.


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    • Proposed as answer by Andrii ButenkoMVP, Moderator Wednesday, September 1, 2010 8:57 AM
    • Unproposed as answer by ysivaram Wednesday, September 1, 2010 9:14 AM
    • Marked as answer by Jim Glass Jr Thursday, September 2, 2010 10:21 PM
    • Unmarked as answer by ysivaram Thursday, September 2, 2010 11:22 PM
    Wednesday, September 1, 2010 8:57 AM
    Moderator
  • Apologies if my question is obvious. How do you override the lookup fields webservice call and modify the page count?
    Wednesday, September 1, 2010 9:15 AM
  • It seems really hard coded...

    If looking into CRM dll's:

     

    AppGrid grid = this.CreateLookupGrid(num2, lookupClass, bindingColumns, additionalParameters, value);

    EntityMetadata metadata2 = instance.GetEntity(num2);

    grid.DataProvider.SortColumns = grid.SortColumns;

    grid.DataProvider.AddParameters(grid.Parameters);

    grid.DataProvider.RecordsPerPage = 11;

    grid.DataProvider.PageNumber = 1;

    grid.DataProvider.Execute();

    grid.DataProvider.Reset();

     


    My blog : http://mscrmtools.blogspot.com

    All my tools on my new dedicated site: MSCRMTools Repository
    • Marked as answer by ysivaram Friday, September 3, 2010 3:42 AM
    Wednesday, September 1, 2010 9:42 AM
    Moderator
  • Apologies if my question is obvious. How do you override the lookup fields webservice call and modify the page count?


    Have you checked url I posted? This one - http://a33ik.blogspot.com/2009/09/overriding-records-per-page-count-for.html

    Following code replaces the count of records returned by request:

              XmlDocument indoc = new XmlDocument();
              indoc.LoadXml((string)context.InputParameters["FetchXml"]);
              
              //There can not be such attribute
              //and this must be handled
              if (indoc.DocumentElement.Attributes["count"] != null)
              {
                indoc.DocumentElement.Attributes["count"].Value = "100";
                context.InputParameters["FetchXml"] = indoc.OuterXml;
              }
    


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Wednesday, September 1, 2010 5:47 PM
    Moderator
  • Andriy:

    Thanks for your suggestion. However I am not referring to the LookupSingle Window. Instead the small auto complete list that appears in a dropdown field when you enter a partial name. I do not think using your method it can be customised. As Tanguy mentioned, it looks like it is hard coded.
    Thursday, September 2, 2010 3:31 AM
  • Hello.

    I checked and it really doesn't work. So it seems that there no easy and supported way to increase the number of lines returned by resolving-feature of lookup.


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    • Marked as answer by Jim Glass Jr Thursday, September 2, 2010 10:22 PM
    • Unmarked as answer by ysivaram Thursday, September 2, 2010 11:22 PM
    • Marked as answer by ysivaram Friday, September 3, 2010 3:42 AM
    Thursday, September 2, 2010 7:01 PM
    Moderator
  • May I know where you got the above source code?
    Friday, September 3, 2010 5:32 AM
  • May I know where you got the above source code?

    .Net Reflector can help you to see source code based on assemblies or executables you have.

    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Friday, September 3, 2010 5:46 AM
    Moderator
  • That's it!

    The hardest part is to find the assembly to look into


    My blog : http://mscrmtools.blogspot.com

    All my tools on my new dedicated site: MSCRMTools Repository
    Friday, September 3, 2010 4:09 PM
    Moderator