Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer Service forum

D365 Portal - Change fields display to Links in the Subgrid on Entity Form

(0) ShareShare
ReportReport
Posted on by 425

Hi,

I have a requirement to change the display of lookup fields displayed in the subgrid(related entity) shown on an entity form to hyper links.

I have followed the below blog which he has done it for entity list, in my case it is subgrid.

http://arpitmscrmhunt.blogspot.com/2017/08/hyperlink-on-lookup-values-in-crm-portal.html

Here is my code, i could find the table,th(header) but not the td, i think as it is getting loaded in async after the whole document is loaded, so the function is not getting executed.

<script type="text/javascript">
        debugger
        $('document').ready(function () {
            debugger
            $('#EntityFormControl_EntityFormView').ready(function () {
                //To make the other field/column's value hyperlink
                $("table[role='grid']").find("td[data-attribute='qtq_shipment']").each(function () { // it is not entering this function.
                //$("td[data-attribute='qtq_shipment']").each(function () {
                    debugger

                    var id = $(this).attr("data-value");
                    var attrList = id.split(",");
                    if (attrList.length > 0) {
                        var idAttr = attrList[0].split(":");
                        var recordId = idAttr[1];
                        recordId = recordId.replace('"', '');
                        recordId = recordId.replace('"', '');

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

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

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

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

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

                });
            });
        });

    </script>

I have tested the above code outside portal in a static html page with the html(for the subgrid div) taken from my portal page, it works fine.

Any thoughts please?

Categories:
  • RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: D365 Portal - Change fields display to Links in the Subgrid on Entity Form

    Ohh Yes, its should be tied up with the sbgrid onloaded event. I missed to add the lines in order to remove the personal code line. Updated so that it can help others as well.

  • Jeevan Kumar Balija Profile Picture
    425 on at
    RE: D365 Portal - Change fields display to Links in the Subgrid on Entity Form

    Hi Ravi,

    Thanks for the response, subgrid loaded event has fixed the issue, thanks.

  • Suggested answer
    Jeevan Kumar Balija Profile Picture
    425 on at
    RE: D365 Portal - Change fields display to Links in the Subgrid on Entity Form

    Hi Venky,

    not sure what is else i have changed from yesterday, i tried this today and it works, i am sure i have tried the same couple of times yesterday. Anyways, thanks for the reply.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: D365 Portal - Change fields display to Links in the Subgrid on Entity Form

    Hi,

    You can refer the below sample . "ALLContacts" is the name of the subgrid-

    =============

    $(document).ready(function () {
        var totalOwnerCount = 0;
        var totalDirectorCount = 0;
        $("#ApplicationContact_SuperFund_Trustee").children(".subgrid.entity-grid").on("loaded", function () {
        $(this).find('table:first tbody tr').each(function () {
            $(this).find("td").each(function () {
                var fieldName = $(this).attr("data-attribute");
                if (fieldName === "new_isowner") {
                    var isOwnerSelected = $(this).attr("data-value");
                    if (isOwnerSelected == "true") {
                        totalOwnerCount = totalOwnerCount + 1;
                    }
                }
                if (fieldName === "new_isdirector") {
                    var isDirectorSelected = $(this).attr("data-value");
                    if (isDirectorSelected == "true") {
                        totalDirectorCount = totalDirectorCount + 1;
                    }
                }
            });
        });
    });

    =================

    Hope this helps.

  • Verified answer
    VENKY KOLAGANI Profile Picture
    270 on at
    RE: D365 Portal - Change fields display to Links in the Subgrid on Entity Form

    Hi Jeevan,

    You can use subgird onload event to customize the fields. Refer the below sample code.

    $(document).ready(function(){
    $('#<subgirdname>').on("loaded", function () {
    // do somthing.
    });
    });

    Thanks,

    Venky

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 231,947 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans