web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

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
I have the same question (0)
  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at

    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.

  • Community Member Profile Picture
    on at

    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

  • Mahendar Pal Profile Picture
    45,095 on at

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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 47 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

#3
#ManoVerse Profile Picture

#ManoVerse 31

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans