none
如何让Lookup显示InActive记录 RRS feed

全部回复

  •  Jim 那个实现的是快速查找 显示InActive记录功能
    Batistuta Cai
    2009年2月13日 1:11
    版主
  • 理解错了,哈哈
    2009年2月13日 1:52
  •  

    You found some inactive records were included in the lookup view result.  You want to know if there is any method to not display these inactive records.  In this case we will focus on this issue.

    All views including lookup views can be edited in customization form.  You can edit the "filter criteria" of some views.  However you are not able to edit the "filter criteria" of some special views including lookup views.  In such case you could update the "filter criteria" via SDK by using "Savedquery" class.  The steps are like -

    1. Obtain the ID of the Savedquery class of the view. To do this, follow these steps:
    a) On the Microsoft Dynamics CRM Web client, click Settings, click Customization, and then click Customize Entities.
    b) Double-click the entity that you want to customize.
    c) Click Forms and Views.
    d) Double-click the view that you want to customize.
    e) In the View page, note the ID of the Savedquery class of the view that appears in the address bar.

    2. Obtain the ColumnSetXML object of the Savedquery class. To do this, in Microsoft SQL Server Management Studio, run the following query against the Microsoft Dynamics CRM database that you use:

    Select ColumnSetXml from SavedQueryBase where SavedQueryId='{<xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx>}'

    Notes -
    - In the query, the <xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx> placeholder represents the ID that you noted in step 1e.
    - The ColumnSetXml object contains the information about the column and the filter criteria of the view. The information about the filter criteria is included in the "filter" XML element.

    For more information about the schema of the "filter" XML element, visit the following Microsoft Web site:
    http://msdn.microsoft.com/en-us/library/bb930489.aspx

    3. Change the ColumnSetXml object.  Update the ColumnSetXml object. To do this, run the following code:
     CrmAuthenticationToken token = new CrmAuthenticationToken();  token.AuthenticationType = 0;
     token.OrganizationName = "<Organization>"; 
     CrmService service = new CrmService();
     service.Url = "http://<CRMServer>/mscrmservices/2007/crmservice.asmx";
     service.CrmAuthenticationTokenValue = token;  service.Credentials = System.Net.CredentialCache.DefaultCredentials;
     savedquery sq = new savedquery();
     sq.savedqueryid = new Key();
     sq.savedqueryid.Value = new Guid("{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}");
     sq.columnsetxml = "<xml got from the 2nd step>";  service.Update(sq);

    Notes -
    - The <Organization> placeholder represents the Microsoft Dynamics CRM organization name that you use.
    - The <CRMServer> placeholder represents the Microsoft Dynamics CRM server name that you use.
    - The <xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx> placeholder represents the ID that you noted in step 1e.
    - The <ColumnSetXml> placeholder represents the ColumnSetXml object that you obtained in step 2.

    4. Publish the customization. To do this, follow these steps:
    a) On the Microsoft Dynamics CRM 4.0 Web client, click Settings, click Customization, and then click Customize Entities.
    b) On More Actions menu, click Publish All Customizations.

    2009年2月19日 8:54