Jeremy Winchell

Copy CRM Contents To The Clipboard

I had a client ask whether or not I could add a button to the Account Form in CRM that would copy and format the address so that they could paste it into an Email or a Word document.  There is a function that you can call from Javascript/VBScript that will allow you to copy text, URLs etc to the clipboard for use in other applications:  window.clipboardData.setData(tag,value);

Step 1: Determine which fields on the Form we need to capture and the schema name

  • In this case we wanted to capture the following:
    • Account Name (name)
    • Street 1  (address1_line1)
    • Street 2  (address1_line2)
    • City (address1_city)
    • State (address1_stateorprovince)
    • Zip Code (address1_postalcode)

Step 2: Write the necessary Javascript in Notepad (case sensitive)

var texttocopy;
try
{
texttocopy = crmForm.all.name.DataValue + '\n';
texttocopy += crmForm.all.address1_line1.DataValue + '\n';
texttocopy += crmForm.all.address1_line2.DataValue + '\n';
texttocopy += crmForm.all.address1_city.DataValue + ', ' + crmForm.all.address1_stateorprovince.DataValue + '  '  + crmForm.all.address1_postalcode.DataValue + '\n';

window.clipboardData.setData('Text',texttocopy);
}
catch(e)
{}

Step 3: Edit the isv.config.xml file to add the Copy Address button

  1. Browse to the isv.config.xml file (<crm_website_folder\_Resources\isv.config.xml)
  2. Make a backup copy of isv.config.xml file
  3. Open isv.config.xml with Notepad
  4. Add the following line between the <Entities></Entities> XML Tags
    1. <Entity name="account">
    2. <ToolBar ValidForCreate="1" ValidForUpdate="1">
    3. <Button Title="Copy Address" ToolTip="Copies the Account Address To The Clipboard" Icon="/_imgs/ico_18_4004.gif" JavaScript=" " />
    4. </ToolBar>
    5. </Entity>
  5. Copy and Paste your Javascript from Step 2 between the double quotes in Line 3
  6. Save the isv.config.xml file

Step 4:  Test the Button

  1. Open up an Account In CRM
  2. Click the Copy Address  button
  3. Open Wordpad/Work/Outlook or some other application
  4. Click Edit -> Paste or hit Ctrl + V
  5. The formatted address from CRM should appear

This will work on IE 6.0 and IE 7.0.  The window.clipboardData.setData function can also be used to copy URLs.  If you want to copy the URL of the open record use this Javascript instead:

var url;
url = window.location.href;
window.clipboardData.setData('Text',url);

Comments

vbullinger said:

That last part seems overkill.  I just press control + N, then copy it out of the address bar.  Then again, I'm lazy.  Although I like to use the term "efficient."

# June 14, 2007 1:11 PM

vbullinger said:

Also, IE 7 keeps the address bar in CRM windows (I like that, it really helps with development).

# August 9, 2007 10:57 AM

AltaGid said:

Hello! Help solve the problem.

Very often try to enter the forum, but says that the password is not correct.

Regrettably use of remembering. Give like to be?

Thank you!

# August 13, 2007 10:19 AM

thebigvip said:

Hi!

My thanks to creators and moderators of this site. This site is the best one I think. I visit it as it’s possible everyday. I really enjoy to talk to posters and most of them became my pen-friends.

So I wish you to gain new posters and not to lose current ones. You are the great team!

_______

Sincerely, [url=http://www.thebigvip.org]Jon Smitt[/url]

# October 20, 2007 6:24 AM

Assitsanenize said:

# March 22, 2008 8:19 PM

FastAtolano said:

Hi!

My name is Jessika!

# October 9, 2008 11:26 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)