locked
Look up filter in CRM4 RRS feed

  • Question

  • Hi,

    I have an entity consisting of 2 lookup fields. The entity name is  TeamUser and the 2 lookup fields are Team and User .
    Entity TeamUser  has N:1 relation with Team and  User  entities.  These are the lookup fields Team and User in the entity.
    While creating a new  record, i need to filter out the User lookup field based on the selected Team from the lookup for Team.
    For eg., if i select TeamA, the lookup for User should contain the members in TeamA.
    The script  is as follows is not working:


    var field = crmForm.all.new_user;
    var actid;

    var lookupItem = new Array;
    lookupItem = crmForm.all.new_team.DataValue;
    if (lookupItem && lookupItem[0] != null)
    {
        actid = lookupItem[0].id;
       
    }


    field.lookupbrowse = 1;

    field.AddParam("search",
         "<fetch mapping='logical'><entity name='New_teamuserExtensionBase'>"
        + "<filter><condition attribute='new_team' operator='eq' value='"
        + actid
        + "' /></filter></entity></fetch>");


    Entity name 'New_teamuserExtensionBase' is the entity got from the relationship.
    'new_user' is the lookup field for User. 
    'new_team'  is the lookup field for Team.
    Please help to correct this script in filtering the User field.
    Thanks in advance ...

    • Edited by Prakashmp74 Wednesday, June 10, 2009 1:18 PM
    • Moved by Mathias Schiffer Wednesday, June 10, 2009 8:59 PM English Language Post (From:Microsoft Dynamics CRM)
    Wednesday, June 10, 2009 12:42 PM

Answers

All replies

  • Hi,

    first, you are shure, that the name of the entity is "new_teamuserextensionbase" and not "new_teamuser"?
    Second, there is an error in the XML-syntax. Delete "</filter>" from the XML.



    Viele Grüße

    Michael Sulz
    axcentro GmbH
    Wednesday, June 10, 2009 4:10 PM
  • Hi Prakash,

    Check this post. Easier script.
    http://mscrmnovice.blogspot.com/2009/06/filtering-lookups-in-crm-4.html

    Hope it helps.
    Best Regards,
    Gagandeep Singh
    http://mscrmnovice.blogspot.com
    Thursday, June 11, 2009 12:02 PM
  • HI Gagan,

    I tried your code and it doesnt seem to work. There seems to be no change in my primary contact lookup. Its still showing me all the contacts and not the ones associated with the account.

    Can you advice?

    Regards
    Prince
    Wednesday, June 17, 2009 8:21 AM
  • Hi
        Have you changed your lookupsingle.aspx page? Here is whole example http://crm.georged.id.au/post/2008/02/16/Filtering-lookup-data-in-CRM-4.aspx

        As for xml code you wrote:

    field.AddParam("search",
         "<fetch mapping='logical'><entity name='New_teamuserExtensionBase'>"
        + "<filter> <condition attribute='new_team' operator='eq' value='"
        + actid
        + "' /></filter> </entity></fetch>");

        What is this 'New_teamuserExtensionBase' entity? Can you write the full names of team and user entity and attributes that are used to build relations between this entities?

        Tthere is no syntax error in your XML. Closing </filter> tag should be just where it is now.


    everything is a matter of probability...
    Wednesday, June 17, 2009 9:35 AM
  • Hi Prince,

    It work well. I don't think you followed the instructions correctly..
    And make sure you have checked the checkbox Event is Enabled on both onLoad and onChange events.
    Best Regards,
    Gagandeep Singh
    http://mscrmnovice.blogspot.com
    Wednesday, June 17, 2009 4:46 PM