Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum

Portals - Populate a Contact lookup field with the currently logged in Contact on an Entity Form

Posted on by 719

What is the best/most efficient way to populate (or set-on-save) a Contact lookup field with the Contact who is currently logged into the Portal? We want to capture the Contact that created the record. 

I've tried using Entity Form Metadata and Setting the Value on Save to Current Portal User, but this only works when the field you are trying to populate is a text field rather than a lookup field. 

I then created a text field and using the Entity Form Metadata, Prepopulated the field with the contactid of the Current Portal User but rather than the guid of the Contact it put the value "Microsoft.Xrm.Sdk.EntityReference" which I can't then use in a workflow to populate the contact field. 

I've also tried checking the Associate Current Portal User field on the Entity Form and selecting my custom Contact lookup field but this doesn't seem to do anything at all (unless I'm misunderstanding what this function should do). 

Is there any way to achieve this using configuration? Or does it require javascript at a minimum?

Does the Associate Current Portal User on Insert functionality on Entity Forms actually work for any portals out there?

  • Byron Dittberner Profile Picture
    Byron Dittberner 235 on at
    RE: Portals - Populate a Contact lookup field with the currently logged in Contact on an Entity Form

    Your explanation is not too clear, are you referring to related records in a grid? Please try to add some screenshots of what you are trying to achieve.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Portals - Populate a Contact lookup field with the currently logged in Contact on an Entity Form

    Can we use a list   and insert  the list on the.child page.then populate the child page ?

  • Suggested answer
    Byron Dittberner Profile Picture
    Byron Dittberner 235 on at
    RE: Portals - Populate a Contact lookup field with the currently logged in Contact on an Entity Form

    Business Case

    You would like when a user creates a record from within their portal profile that the record is associated with the portal user that is currently logged in and you wish that the lookup field to the contact is pre-populated onLoad of the form.

    Solution

    Firstly, yes this can be done and the good news is that it is fairly simple.

    Scenario - You have created a custom entity for which the portal user has the ability to create records, however, you do not want the user to be able to associate the record to another contact, instead, the contact lookup field should auto-populate with the name of the logged-in portal user.

    Before you get started with the below process you need to make sure you have a lookup field to the contact entity on the form for which you would like to prepopulate the contact's name.

    in the below sample I have created a custom Lead Entity, just for demo purposes.

    Let's get started...

    1. Navigate to Portals >> Entity Forms
    2. Search for the name of the entity forms you created, in my case "Leads" and you should get the following result
      1. entity-list.JPG
    3. Open the record which shows, "create" within the name
    4. first I would create an association between the new record and the portal user that created the record. Once the form is open, scroll down and look for a section labelled, Associate Current Portal User on Insert, in my case I have called a contact an Agent. configure the settings as per the below image;
      1. associate.JPG
    5. Next, scroll down to the TAB labelled, Entity Form Metadata, on the right of the GRID, click on the + to create a record.
      1. efm.JPG
    6. Configure the settings as follows;
      1. The Attribute Logical Name is the name of the lookup field that is on your form that is displayed to the portal user when creating a record 
      2. pastedimage1571674172501v1.png
      3. The form attribute is the related entity, in this case, the Contact Entity
      4. pastedimage1571674234162v2.png
    7. Click on save

    And that's it, you're done.

    NB! don't forget to refresh the portal before testing, I would recommend selecting CRTL + F5 which will clear any cached data in your browser. if for any reason the change does not take effect you may need to clear the Portal Cache. You find this to be the case when you have implemented a number of changes.

    To reset your Portal Cache, follow the below steps;

    1. You need to log in as a portal user with the Administrator Web Role
    2. Once logged in, open a new browser window within the same browser and enter the following URL
      1. yourPortalFullAddress/_services/about
    3. Click on clear cache
    4. now refresh your portal website. 

    If you found this post solves your requirement, please mark as Verified

  • Suggested answer
    Mahendar Pal Profile Picture
    Mahendar Pal 45,041 on at
    RE: Portals - Populate a Contact lookup field with the currently logged in Contact on an Entity Form

    This does not matter, it will work with every custom lookup, current screenshot is from account entity.

  • Verified answer
    Inksrm Profile Picture
    Inksrm 719 on at
    RE: Portals - Populate a Contact lookup field with the currently logged in Contact on an Entity Form

    I managed to resolve this by creating a new Contact lookup field and using that to associate to the current portal user.

    I'm still unsure as to why it didn't work for my original Contact lookup field  Â¯\_(ツ)_/¯

  • Inksrm Profile Picture
    Inksrm 719 on at
    RE: Portals - Populate a Contact lookup field with the currently logged in Contact on an Entity Form

    Hi Mahender,

    As mentioned above I have tried using that functionality to associate the current portal user by using a custom Contact lookup field but it doesn't work.

    I notice in your screenshot you have the field Created by (Portal Contact) (adx_createdbyportalcontactid) available. This field is not there for me. Should it be?

    Thanks

  • Inksrm Profile Picture
    Inksrm 719 on at
    RE: Portals - Populate a Contact lookup field with the currently logged in Contact on an Entity Form

    Hi Mahender,

    As mentioned above I have tried using that functionality to associate the current portal user by using a custom Contact lookup field but it doesn't work.

    I notice in your screenshot you have the field Created by (Portal Contact) (adx_createdbyportalcontactid) available. This field is not there for me. Should it be?

    Thanks

  • Mahendar Pal Profile Picture
    Mahendar Pal 45,041 on at
    RE: Portals - Populate a Contact lookup field with the currently logged in Contact on an Entity Form

    Hi,

    Yes, you can use Associate Current Portal User on Insert like below

    savecontact.png

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,946 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,420 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans