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 CRM (Archived)

How to make record URL as hyperlink in Plugin code?

(0) ShareShare
ReportReport
Posted on by

Hi Guys,

Requirement is to insert record URL (GUID) as hyperlink in plugin code. I was able to frame the url as a text. 

But i need to make it as hyperlink.. need your help in doing it.

Thanks,

Vignesh Mohan

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Thomas David Dayman Profile Picture
    11,323 on at

    Heres how I did mine.

    I stored the Guid in a text field and then created a business rule to populate the 'record' as a URL by reading the other fields.

    2627.Screenshot_5F00_8.png

    2627.Screenshot_5F00_8.png

    5342.Screenshot_5F00_9.png

  • Community Member Profile Picture
    on at

    I need to send this link in email description. So I need to include this in a plugin code. Any possibility of making in plugin code?

  • Verified answer
    jestuder Profile Picture
    158 on at

    The code will be slightly different if your using Early Binding or Late Binding.  But the basic premise is the same.

    string hyperlink = "<a href='" + CRM FIELD + "'></a>" ;

    If you store the value in CRM like @ Thomas recommended.  Personally I would go with this approach so if the URL needs to be changed you don't need to change code in the plugin.  But if you want to do it within the plugin then do the concatenation in code:

    string hyperlink = string.format("{0}{1}{2}{3}{4}{5}", "<a href='https://crmurl.com", CRM Record Name, "&pagetype=entityrecord&id=%7B", CRM Record GUID,"%7D", "'></a>");


  • Community Member Profile Picture
    on at

    Use the following method:

    public static string BuildEntityUrl(IOrganizationService crmService, string orgName, string entityName, Guid entityId, string domainName = null)
    {
        // retrieve code
        RetrieveEntityRequest request = new RetrieveEntityRequest();
        request.LogicalName = entityName;
        RetrieveEntityResponse response = (RetrieveEntityResponse)crmService.Execute(request);
        int entityCode = response.EntityMetadata.ObjectTypeCode.Value;
    
        // template urls NB: use your cloud zone (es. crm4 for west europe)
        string onpremiseurl = $"https://{domainName}/{orgName}/main.aspx?etc={entityCode}&id=%7b{entityId}%7d&pagetype=entityrecord";
        string cloudurl = $"https://{orgName}.crm4.dynamics.com/main.aspx?etc={entityCode}&id=%7b{entityId}%7d&pagetype=entityrecord";
    
        // On Premise url
        if (!string.IsNullOrEmpty(domainName))
            return onpremiseurl;
                
        // Cloud url
        return cloudurl;
    }

    Hope it helps!

    If you found the answer helpful, please mark as Verified 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • Verified answer
    Community Member Profile Picture
    on at

    Thanks James, anchor tag works for me

    <a href= 'http://www.adonext.com&#39;>Click Here</a>

  • ampatil13@gmail.com Profile Picture
    115 on at

    Hi... Is it possible to retrieve/fetch the domain name in onpremise.

    string onpremiseurl = $"https://{domainName}/{orgName}/main.aspx?etc={entityCode}&id=%7b{entityId}%7d&pagetype=entityrecord";

    Thanks in Advance.

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 CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans