Solved

Filter a lookup view

Posted on 2009-07-02
8
517 Views
Last Modified: 2012-08-14
I have a form with two lookup fields:
The first one is called 'workinggroupid'. The second one is called 'alternateid'. I would like to filter the 'alternateid' lookup by the selected 'workingroupid'.

I've added the following code in the lookupsingle.aspx file:

<script runat="server">
protected override void OnLoad( EventArgs e )
{
      base.OnLoad(e);
      crmGrid.PreRender += new EventHandler( crmgrid_PreRender );
}
void crmgrid_PreRender( object sender , EventArgs e )
{
    // As we don't want to break any other lookups, ensure that we use workaround only if
    // search parameter set to fetch xml.
    if (crmGrid.Parameters["search"] != null && crmGrid.Parameters["search"].StartsWith("<fetch"))
    {
        crmGrid.Parameters.Add("fetchxml", crmGrid.Parameters["search"]);  
        // searchvalue needs to be removed as it's typically set to a wildcard '*'
        crmGrid.Parameters.Remove("searchvalue");  
        // Icing on a cake - ensure that user cannot create new contact outside of the account
        // and then select it.
        this._showNewButton = false;
    }
}

and in the OnLoad script I've added the following code:

var field = crmForm.all.new_workinggroupid;
if(crmForm.ObjectId == null)
{
    // Disable lookup for new account record as there can be no contacts
    field.Disabled = true;
}
else
{
    // Ensure that search box is not visible in a lookup dialog
    field.lookupbrowse = 1;
   
    // Pass fetch xml through search value parameter
    field.AddParam("search",
     "<fetch mapping='logical'><entity name='MemberOf'>"
    + "<filter><condition attribute='new_workinggroupid' operator='eq' value='"
    + crmForm.all.new_workinggroupid.DataValue[0].id.toString()
    + "' /></filter></entity></fetch>");
}



And.... does not work. Any idea????
Thanks in advance
0
Comment
Question by:chonichon
  • 5
  • 3
8 Comments
 
LVL 11

Expert Comment

by:rakeshAgarwal
Comment Utility
Hi  which version of crm you are using this will not work in crm 4.0 .
0
 
LVL 11

Expert Comment

by:rakeshAgarwal
Comment Utility
In crm 4.0

http://www.dynamicsexchange.com/crm-answer-site/default.aspx

just search for "filter lookup"

you wil get solution to your answer

thanks
Rakesh
0
 

Author Comment

by:chonichon
Comment Utility
CRM 4.0
0
 
LVL 11

Expert Comment

by:rakeshAgarwal
Comment Utility
just check the above link
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 11

Expert Comment

by:rakeshAgarwal
Comment Utility
0
 

Author Comment

by:chonichon
Comment Utility
I've done the following changes:
In the onload event of the form I've added:

document.FilterLookup = function(source, target)
{
    if (IsNull(source) || IsNull(target)) { return; }
    var name = IsNull(source.DataValue) ? '' : source.DataValue[0].name;
    target.additionalparams = 'search=' + name;
}

In the onchange event of the Workinggroup field on the form I've added:
document.FilterLookup(crmForm.all.awx_new_workinggroup, crmForm.all.awx_new_alternateid);

And, does not work.
0
 
LVL 11

Accepted Solution

by:
rakeshAgarwal earned 500 total points
Comment Utility
hope you  have remove d this code also

>>>I've added the following code in the lookupsingle.aspx


please go to

Have you checked that blog , have you added column to quick find.

regards
Rakesh

0
 

Author Comment

by:chonichon
Comment Utility
Thanks....
Now it works...
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This is a walkthrough guide I wrote whilst upgrading my on-premise MS Dynamics CRM 3.0 deployment to 4.0. This covers the actual installation of the product to a working level for my system, I ran into a lot of issues that the steps below fixed so h…
On Sep 22nd 2014 Microsoft released Update Rollup 1 for Microsoft Dynamics CRM 2013 Service Pack 1 and back in July Update Rollup 3 was released.  So we now have:   Update Rollup 1Update Rollup 2Update Rollup 3Service Pack 1Update Rollup 1 for S…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now