Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

link under text using JS in CRM

(0) ShareShare
ReportReport
Posted on by 88

Hello everyone!

I have a message on form -> "The opportunity Opp_Name has been approved"

I would like to click on Opp_Name and to be redirected to the specified opportunity form.

I have tried to do something like this:

function getOpportunityLink() {
var link = document.createElement('a');
var text = document.createTextNode("Opportunity Name");
link.appendChild(text);
link.title = "Opportunity Name";
link.href = "www.google.com";
//document.body.appendChild(link);
return link.outerHTML;
}

In the CRM it shows me like this  ->>>  "The opportunity <a title="Opportunity Name" href="www.google.com">Opportunity Name</a> has been approved"

What am I doing wrong?

*This post is locked for comments

  • Suggested answer
    Emre GULCAN Profile Picture
    2,379 on at
    RE: link under text using JS in CRM

    Hi,

    You can use this sample code. You should add "ClientGlobalContext.js.aspx" to your webresource to use Dynamics 365 context and clientside SDK.

    For more information please look at https://msdn.microsoft.com/en-us/library/gg328541.aspx and https://msdn.microsoft.com/en-us/library/jj602956.aspx#BKMK_OpenEntityForm 

    <!DOCTYPE html>
    
    <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta charset="utf-8" />
        <title></title>
        <script type="text/javascript" src="../../ClientGlobalContext.js.aspx"></script>
        <script type="text/javascript">
            function openOpportunityForm(id) {
                Xrm.Utility.openEntityForm("opportunity", id);
            }
        </script>
    </head>
    <body>
        The opportunity <a onclick="openOpportunityForm('628CF01A-AED1-E411-80EF-C4346BAC7BE8')">YOUR OPPORTUNITY NAME</a> has been approved. Please click <a onclick="openOpportunityForm('628CF01A-AED1-E411-80EF-C4346BAC7BE8')">here</a> for details
    </body>
    </html>

    I added my webresource to contact form (for demo purpose) and show like below, if you click opportunity name or "here", my sample opportunity open

    5822.01.PNG

  • Community Member Profile Picture
    on at
    RE: link under text using JS in CRM

    Is that in a web resource?

    Otherwise what you're trying to accomplish is not supported, and not even possible under a standard warning\error message or at a field level.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: link under text using JS in CRM

    Hello,

    Whare you want to show this message?

    if you want to show an alert or in any field then it  is not possible

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 Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans