Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Portal Entitylist custom javascript problem: get ID from data-value

(0) ShareShare
ReportReport
Posted on by

Hi, 

I'm trying to build a link from a column in an Entitylist to redirect to a webform from a related entity. The javascript I'm trying to use is based on that posted here, but isn't working for me in the way that I want: https://community.dynamics.com/crm/b/thinkdynamicdodynamic/posts/crm-portals-add-hyperlink-on-custom-attribute-in-entity-list.

The javascript I've put together is as follows:

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

//To make the other field/column's value hyperlink
$("td[data-attribute*='xxxx_publishingreference']").each(function() {

var id=$(this).attr("data-value");


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

// 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>");

});
});
Unfortunately the "data-value" pulls back the following detail: data-value="{"Id":"85030da1-3b03-eb11-a813-000d3a7ed2f2","LogicalName":"xxxx_onlinedecisions","Name":"P-001009","KeyAttributes":[],"RowVersion":null,"ExtensionData":null}"
All I want is to get just the "Id" part of the string. I've tried a JSON parse, but this didn't work (although I may have used it wrong).
Any ideas?
Cheers
Ralph
  • Mahendar Pal Profile Picture
    45,095 on at
    RE: Portal Entitylist custom javascript problem: get ID from data-value

    You have to get it by playing js only, so if you are getting id correctly now  it should work fine.

  • Community Member Profile Picture
    on at
    RE: Portal Entitylist custom javascript problem: get ID from data-value

    Thanks Mahender - I'd had to change this original js because it was pointing to tr/data-id which wasn't the record GUID I needed. I've actually fixed this now, although the approach is a bit luddite:

    var id=$(this).attr("data-value").slice(5,43);

    This just brings me back the ID part of the value string/array.

    However, if there's something more elegant I'd be grateful to hear it!

    Cheers

    Ralph

  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at
    RE: Portal Entitylist custom javascript problem: get ID from data-value

    Hi,

    I suggest you to use developer tools to check properties of the entitylist and first try this in the console to make sure you are getting id part.

    var id=$(this).attr("data-value");

    or

    var id=$(this).closest('tr').attr("data-id"); //as suggested in the post

    Once you got it then test it will the js, don't have access to any demo portal otherwise I could check it.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,302 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,114 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans