web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Dynamic lookup filter based on logged in user account

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Suggested answer
    Friyank Profile Picture
    944 on at

    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

  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at

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

  • Indra Tata Profile Picture
    110 on at

    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
    Arpit Shrivastava Profile Picture
    7,518 User Group Leader on at

    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
    110 on at

    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
    Justinjose Profile Picture
    2,707 on at

    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

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans