"тнιѕ вℓσg ¢συℓ∂ ѕανє уσυя мσηєу ιƒ тιмє = мσηєу" - ∂.мαηנαℓу

Saturday 25 June 2011

How to clear Lookup in CRM 2011/ Lookup filtering and clearing lookup in CRM 2011 / How to pass argument to js function in CRM 2011

As you all know, one of the best features of CRM 2011 is lookup filtering just because it reduces coding. Consider that we are filtering second lookup based on first one. We need to clear the second lookup whenever the user change the selection of first lookup.Lookup feature Reference: http://crmdm.blogspot.com/2011/04/lookup-fitering-feature-in-crm-2011-or.html

Scenario:
2 lookups Country and City

When the user selects UK from first lookup then second lookup lists cities belongs to UK( based on lookup filtering feature)
Now the user would like to update Country to Denmark. so when the user selects country as Denmark then the city lookup should be cleared. And then the user gets a chance to choose cities belongs to Denmark.

This could be achieved by simple javascript by passing an attribute.


Code Snippet:

function SetLookupNull(lookupAttribute)
{
var lookupObject = Xrm.Page.getAttribute(lookupAttribute);



if (lookupObject != null)
 {

Xrm.Page.getAttribute(lookupAttribute).setValue(

null);

}

}

The function call is on the onchange event of first lookup


Please note that we need to pass the attribute name of the lookup which should be cleared.


The key advantage of the above function is reusability. You could clear any lookup value as per the need by supplying the attribute name as shown.

5 comments:

  1. It is not working .......... :\

    ReplyDelete
  2. sorry for my first comment......
    It's works fine

    ReplyDelete
  3. Thanks for providing your information and keep share with us Azure Online Course Bangalore

    ReplyDelete
  4. "Customized CRM Software Solution and CRM Applications Development Services India For Your Business" - Hire the expert custom CRM software developers for your crucial projects. Our highly motivated professionals are ready to serve you 24*7.

    ReplyDelete

  5. Nice blog..! I really loved reading through this article. Thanks for sharing such a amazing post with us and keep blogging...
    CRM Software in Denmark

    ReplyDelete