Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Filter record using other than Account and Contact entity relation in CRM Portal

Posted on by Microsoft Employee

Hi All,

I have a Entity in crm which contains "State" and "country" field. I want to use this entity in CRM Portal with a filter like, It should filter the record based on logged in user country value.

Any type of help would be appreciated. 

Thanks in Advance.

*This post is locked for comments

  • Verified answer
    Nadeeja Bomiriya Profile Picture
    Nadeeja Bomiriya 6,804 on at
    RE: Filter record using other than Account and Contact entity relation in CRM Portal

    Hi Pankaj,

    In that case, you could try below.

    On the Web Page Copy (HTML), use liquid to write the user's country to DOM.

    <div id="pfx_contact_country">{{ user.pfx_contact_country }}</div>

    If the country field is a lookup then use 

    user.pfx_contact_country.id

    Then in Entity List Custom JavaScript section, write JavaScript to remove tr element's that doesn't match contact's country.  This code give access to the grid's onload event.

    $(document).ready(function (){
      $(".entitylist.entity-grid").on("loaded", function () { 
         $(this).children(".view-grid").find("tr").each(function (){ 
            // Get the contact's country - value created by liquid
            // Get this elements country
            // IF they don't match, remove element
            // Note: Make sure to not delete th element        
         }); 
      });
    });

    For more information about this JavaScript code please see below.

    https://community.adxstudio.com/products/adxstudio-portals/documentation/configuration-guide/entity-list/attributes-relationships/

    Cheers,

    Nadeeja

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Filter record using other than Account and Contact entity relation in CRM Portal

    Hi Nadeeja,

    Thanks for the reply but my requirement is to filter the record for the Entity List on portal ,not required to populate the country on Entity form.

  • Suggested answer
    Nadeeja Bomiriya Profile Picture
    Nadeeja Bomiriya 6,804 on at
    RE: Filter record using other than Account and Contact entity relation in CRM Portal

    Hi Pankaj,

    Assuming you are trying to populate the country field in an Entity Form or Web Form, you could try below approach.

    1. First you need to get the logged in user's country in to the DOM.  You can do this using Liquid.

    https://community.adxstudio.com/products/adxstudio-portals/documentation/configuration-guide/liquid-templates/objects/user/

    For example:

    If you enter below in Copy (HTML) section of a web page (open source view not rich formatting),

    <div>User ID  = {{ user.id }}<div>
    <div>Country  = {{ user.prefix_country }}<div>

    You will see below result.

    User ID = 817591e8-9b83-e611-9424-0050569b556d

    Country = Australia

    2. Now you can use jQuery to populate the country field on you custom entity's Entity Form.

    $(document).ready(function() {
       $("#prefix_country").val("Australia");
    });


    https://community.adxstudio.com/products/adxstudio-portals/documentation/configuration-guide/entity-form/attributes-and-relationships/custom-javascript/

    Hope this helps.

    Cheers,

    Nadeeja

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans