?
Solved

Filter a lookup view

Posted on 2009-07-02
8
Medium Priority
?
527 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 11

Expert Comment

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

Expert Comment

by:rakeshAgarwal
ID: 24769771
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
ID: 24770428
CRM 4.0
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 11

Expert Comment

by:rakeshAgarwal
ID: 24770503
just check the above link
0
 

Author Comment

by:chonichon
ID: 24771008
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 2000 total points
ID: 24771251
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
ID: 24772001
Thanks....
Now it works...
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For cloud, the “train has left the station” and in the Microsoft ERP & CRM world, that means the next generation of enterprise software from Microsoft is here: Dynamics 365 is Microsoft’s new integrated business solution that unifies CRM and ERP fun…
Desired Skill Set for Microsoft Dynamics CRM Technical Resources – Part II
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

764 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