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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Copy Link button javascript

(0) ShareShare
ReportReport
Posted on by 1,328

I'm trying to use this code to add a 'Copy Link' button using Ribbon Workbench. I got this from a bookmarklet that was provided in another thread. After publishing, nothing happens when I click the button. Can someone help me with my code?

function copyLink(){
    var contentPanels=Array.from(document.querySelectorAll('iframe')).filter(function(d){return d.style.visibility!=='hidden'});
    if (contentPanels && contentPanels.length > 0) {
        var Xrm = contentPanels[0].contentWindow.Xrm; var entityId = Xrm.Page.data.entity.getId();
        if(entityId){
            prompt('Ctrl+C to copy to clipboard',Xrm.Page.context.getClientUrl()+'/main.aspx?etn='+Xrm.Page.data.entity.getEntityName()+'&id='+entityId+'&newWindow=true&pagetype=entityrecord');
        }
    }
}


Code from bookmarklet:

javascript:(function(){var%20contentPanels=Array.from(document.querySelectorAll('iframe')).filter(function(d){return%20d.style.visibility!=='hidden'});if(contentPanels&&contentPanels.length>0){var%20Xrm=contentPanels[0].contentWindow.Xrm;var%20entityId=Xrm.Page.data.entity.getId();if(entityId){prompt('Ctrl+C%20to%20copy%20to%20clipboard',Xrm.Page.context.getClientUrl()+'/main.aspx?etn='+Xrm.Page.data.entity.getEntityName()+'&id='+entityId+'&newWindow=true&pagetype=entityrecord');}}})();void%200;

4024.Capture.PNG

*This post is locked for comments

I have the same question (0)
  • Verified answer
    epark06 Profile Picture
    1,328 on at

    Resolved using:

    function copyLink(){

       var entityId = Xrm.Page.data.entity.getId();

           if(entityId){

               prompt('Ctrl+C to copy to clipboard',Xrm.Page.context.getClientUrl()+'/main.aspx?etn='+Xrm.Page.data.entity.getEntityName()+'&id='+entityId+'&newWindow=true&pagetype=entityrecord');

           }

       }

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans