CRM Blog

Wednesday, March 12, 2008 - Posts

Using Windows “Copy To Clipboard” Functionality In CRM
by Danny Varghese 03.12.08

Comments    No Comments

Using The Clipboard

A really neat use of creating a button in Microsoft CRM is using the Windows “copy to clipboard” functionality.  Many of our clients have asked for a button on the Account and Contact forms that would, on click, copy all the address information to the Windows clipboard so that they could paste it in e-mails, documents, notes, etc.  Here’s how to do it:
  1. Edit the ISV.Config.xml file to add a button to the Account and Contact forms.
  2. Add a “JavaScript” parameter to the button configuration to, using good programming practices, call a JavaScript method that exists in a single file location.  This is so that both any number of entities can access the same method in one place.
  3. Write a JavaScript function to build a string that you want to be copied to the clipboard.
  4. Pass that into the function I created below, that calls the windows copy to clipboard function:
function copyTextToClipboard(textToCopy){             if (textToCopy != null)             {                        //copy data to windows clipboard                           if (window.clipboardData)                       

   {

       window.clipboardData.setData("Text", textToCopy);             

   }

 }

} Shortfalls

The windows clipboard does have a few shortfalls:

1.       Each time you copy, the data does replace whatever the old one was

2.       Each string copied does not carry over to other sessions

3.       You can’t easily preview the copied string

4.       Only one string can be stored at a time.

Filed under: