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

Announcements

News and Announcements icon
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

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Hello,

    Whare you want to show this message?

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

  • Community Member Profile Picture
    on at

    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
    Emre GULCAN Profile Picture
    2,379 on at

    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

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
RichardM Profile Picture

RichardM 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans