locked
How to Filter a Lookup RRS feed

  • Question

  • Hi,

    In our system it has following relationships among entities. In this scenario we can add event bookings against an event. Event bookings should add multiple attendees to it. When you are adding attendees to an event booking, it needs to select a package. So that Package lookup filed is in the Event Attendee form. Problem I’m facing is when i click on the Package lookup in the Event Attendee Form It will show all the packages that I created. Not filtering the packages for the particular Event that the event booking is attached. This may be because of not having the Event Lookup field in the Event Attendee Form. But we don’t need to let users to again select the event EventAttendeeForm. Because the particular event booking is already attached to the event. Can anyone tell me that how we can achieve this with CRM 2011.

    Filter Criteria should be-

    Package Lookup should filter Packages where Package.EventId==EventBooking.EventId inside the Event Attendee Form.

     

    Thank you.

    Thursday, December 8, 2011 1:10 PM

Answers

  • Hi Tisara,

    Out of the box, CRM 2011 allows you to filter lookups by related entities, but for this '2 level deep' filtering you will need to have some javascript.

    In javascript you can dynamically create a view and set this as the default view of your lookup at runtime. To create your view, you will need to query the related 'Event Booking' to get the 'Event' id. This will involve a service call to retrieve the data from CRM (using the REST endpoint is the simplest option here). Once you have that information, you will be able to create your dynamic view using FetchXml.

    Here is an example of creating the view: http://crmdm.blogspot.com/2011/05/lookup-filtering-in-crm-2011-using.html

    And here is some sample code for retrieving data in CRM using the REST endpoint: http://msdn.microsoft.com/en-us/library/gg334427.aspx

    I hope that helps you get started.

    Kirsten

    Thursday, December 8, 2011 2:53 PM