Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Dynamic lookup filter based on logged in user account

Posted on by 110

Hi guys,

I want to filter the lookup field dynamically based on login user account. Let's suppose, I have many schools in my application like school A, B, C. When contact from School A logged in, he must be able to retrieve the students belongs to School A using lookup field. 
Note: I'm retrieving the students from student(custom) entity not from Contact.

Please help to accomplish my requirement.

Thank you, 

Indra

*This post is locked for comments

  • Suggested answer
    Justinjose Profile Picture
    Justinjose 2,707 on at
    RE: Dynamic lookup filter based on logged in user account

    Hi Indra,

    if you creating Case Entity as portal form then - 

    1. Student Entity Form

    • Create an Account look field with in the Student entity form.

    2. Case Entity Form

    • Create a Student look up field with in the Case entity form.
    • Then mark related record filtering in the  Student entity look up field-  Student entity look up field based on the Account field. Please see below image (Case entity form)

    4834.Capture4.PNG

    • Give set Entity Permission to Student Entity - Scope = Account, Add "Authenticated User" web role
    •  When you are login into the portal make sure the contact is associated with account.

    Thanks and If you have any further queries please let me know

    Justin Jose

  • Indra Tata Profile Picture
    Indra Tata 110 on at
    RE: Dynamic lookup filter based on logged in user account

    Hello Arpit,

    I tried the way you suggested, but it doesn't work. As i have school (Account) and Student as Custom entity, but when i tried to customer filter as you shown in image it doesn't work. I tried with the field studentwithaccount. I'm confused on which entity i has to create portal form? I tried in all three possible ways like in case entity, account(school) entity, Student entity. All three ways are in vain. Hope you understand the way I tried.

  • Suggested answer
    Arpit Shrivastava Profile Picture
    Arpit Shrivastava 7,518 User Group Leader on at
    RE: Dynamic lookup filter based on logged in user account

    Hi Indra,

    If I understood your requirement correctly,

    • Here, School information you are storing in Account (or might be any custom entity) Entity.
    • Student information you are storing in Student Entity.
    • Each Student has a contact in CRM in order to log onto the Portal.
    • You want, if any student login to the portal, he/she should be able to see the students of his/her school in any custom lookup field.

    What you can do is:

    Assuming you already have done this-

    • On Contact entity, keep one lookup field of School (ignore if already having) in order to store School Information.
    • On Student entity, keep one lookup field of School (ignore if already having) in order to store School information.
    • Keep two Lookup fields ('Logged In Contact School' and 'My School Students') on the form that you are exposing on the portal to show the filtered students.
    • Enable lookup filtering on the 'My School Students' lookup in CRM - To view only those students record where Selected School record in 'Logged In Contact School' equals to all those students of Student entity who belongs to that school. 

    or in easy language

             Lookup Filtering Condition would be:

      Show only those Students in 'My School Students' lookup, where School field value of the Student record    = School field value in 'Logged In Contact School'

    In below example, we are filtering contacts based on Account. In the same way, you have to filter Students based on School.

    2447457.Capture.PNG

    • This will give only those students in 'My School Students' lookup which is equal to school selected in 'Logged In Contact School'
    • Now the interesting part is, how we would get Logged In Portal user (Student's) School name. For this, we will use Entity Form Metadata.
    • In 'Logged In Contact School' field auto-populate logged In Portal user's School using Entity Form Metadata. We are already keeping School information on each Contact record.
    • So this way, when you open form on the portal - each portal logged in user's school will get auto-populated automatically in 'Logged In Contact School' field and your 'My School Students' lookup will have only logged in student's school's students.

    You can refer below link to see how we can auto-populate Portal Logged In user information on entity form 

    https://community.dynamics.com/crm/f/117/t/254468

    http://dynamicscrmcoe.com/how-to-auto-populate-field-adxstudio-entity-form/

    Mark, it verified, If you are able to understand the solution of your requirement.

    Cheers

    Arpit

    https://arpitmscrmhunt.blogspot.in

  • Indra Tata Profile Picture
    Indra Tata 110 on at
    RE: Dynamic lookup filter based on logged in user account

    Hi Friyank Parikh,

    My worries about on Portal side not in crm side. In Portal when i logged in with school A login credentails, I must be restricted to get the details of that school students only from lookup.

    Thank You,

  • Suggested answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: Dynamic lookup filter based on logged in user account

    Agree with Friyank - above two options should be able to help you!

  • Suggested answer
    Friyank Profile Picture
    Friyank 944 on at
    RE: Dynamic lookup filter based on logged in user account

    You can create a new view and set that view in the lookup field properties.

    or

    You can use addPreSearch to filter the lookup results

    Check below link

    dynamics365.ie/dynamics-crm-2013-filter-lookup-dialogs

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans