Thursday, 25 January 2018

CRM Portals - Add Hyperlink On Custom Attribute In Entity List












By default, In Entity List If you enable settings to view Entity List records, It shows hyperlink only on very First Column of Entity List.

Refer below link to configure Details View Setting (to view entity list record) in Entity List.

https://community.adxstudio.com/products/adxstudio-portals/documentation/configuration-guide/entity-list/view-details-page/

https://community.dynamics.com/crm/b/nishantranaweblog/archive/2017/02/02/using-entity-list-to-show-crm-data-in-portal-in-dynamics-365




For Example - In above example, I have exposed Case Entity List on Portal, It showing hyperlink on only Case Number, But If I want to make the hyperlink on any other Field it is not possible Out of Box.

So In this article, I will walk you through the way to make the other Column Value Hyperlink of any Entity List in Portal.


Code Snippet:


$('.entitylist').on("loaded", function () {

//To make the other field/column's value hyperlink
$("td[data-attribute*='Field's SCHEMA NAME or Field's HTML Control Id']").each(function() {

// For Example
$("td[data-attribute*='title']").each(function() {

// Get guid of record - might need to change this line a bit to get the record guid
var id=$(this).closest('tr').attr("data-id");

// Partial URL of webpage where you want to redirect the user or the page from which your Edit Entity Form is associated
var pagewhereToRedirect = "Web page Partial URL";

var pagewhereToRedirect = "edit-case"; // For Example

// Construct the URL
var redirect=window.location.href+pagewhereToRedirect+"/?id="+id;

// Make the field value Hyperlink
var text=$(this).text();

$(this).html("<a href="+redirect+">"+text+"</a>");

});

});


Note: In above code, you just need to change the highlighted value only.

To get Field's SCHEMA NAME or Field's HTML Control Id

Press F12 or Right Click  >  Inspect





















To get Web page Partial URL

Right Click on Hyperlink and Copy Link Address. The highlighted part is the partial URL of the webpage.

https://arpitdynamics.microsoftcrmportals.com/support/edit-case/?id=2c29a2bb-bb01-e811-90cd-0003ff913670









5 comments:

  1. I am trying to hyperlink email which is one of the attribute in the entity list. Is this possible using the same code above?
    I have tried to this under Entity List> JS

    ReplyDelete
  2. can we add hyperlink to createdon field?

    ReplyDelete
  3. Great Post and is really helpful. I just have a question, could you assist me in rather redirecting to a different page maybe open up a modal dialog screen so that you don't have to loose focus from the page you are on?

    ReplyDelete
    Replies
    1. Please have a look my recent article, which opens the lookup record in modal popup.

      https://arpitmscrmhunt.blogspot.com/2020/07/powerapps-portals-lookup-editor-control.html

      Hope it helps.

      Cheers

      Delete
  4. Easily transform your writing with these 5 tips for writing that the experts use. These habits are guaranteed to get your writing results to the next level.
    https://www.bloglovin.com/@mahendrakumawat6/what-every-student-needs-to-know

    ReplyDelete

Blogger Widgets