Tip #1044: Display lookups as hyperlinks in portal entity list

Entity lists in the Dynamics 365 portals do not have any special handling for the lookups – they just render the display names. Fair enough, after all, how is the rendering code supposed to know what page to link to?

If you are comfortable with liquid in portals then the task is relatively easy. Just use the entity list advanced sample and modify it to render lookups as hyperlinks. (If you find that someone butchered a copy-pasting of Adxstudio documentation, go to the nicely formattedĀ source while it’s still available).

If you prefer standard entity list rendered by one of the built-in templates, then a bit of JQuery magic will do the job. Use the sample script as a starting point and just wrap the content of the lookup column using <a> tag. For example, the following code will convert any quote lookup it comes across in the entity list into a link to “/quote/?id=” page.

$(document).ready(function (){
  $(".entitylist.entity-grid").on("loaded", function(){
    $(this).children(".view-grid")
      .find("td[data-attribute='quote']")
        .each(function(){
          $(this).wrapInner("<a href='/quote/?id=" 
          + $(this).data('value').Id + "'</a>");
    })
  });
});

 

Leave a Reply

Your email address will not be published. Required fields are marked *