Menu Color:
Banner Color:
Main Color:
Header Image:
  • background1
  • background2
  • background3
  • background4
  • background5
  • background6
  • background7
  • background8
  • background9
en-USes-ES
Search
en-USes-ES
March 29, 2017
You are here : Computer Blog
Blog Archive
View Blog
 
     

Copy CRM 4.0 details to the clipboard for easy pasting.

Nov 06 2008

A frequent process many users perform is copying a contacts information to another location, typically an e-mail. With CRM this requires copying and pasting several fields.

I do not like to re-invent the wheel so I searched for some code to perform this task. What I found were many half baked solutions that did not properly format blank lines and did not have any error control. Others just did not fit the bill for other reasons. However they all provided a good starting point for me, so thank you everyone.

Here is my current  version of a customization to perform the copy process. This creates a custom button and should be placed in the IsvConfig, now a part of customizations.xml.

<Entity name="contact">
 <MenuBar>
  <CustomMenus />
 </MenuBar>
 <ToolBar ValidForCreate="1" ValidForUpdate="1">
 <Button JavaScript="
  var copyaddr = '';
  var buff;
  try{
   buff = crmForm.all.firstname.DataValue;
   if(buff != null) copyaddr += buff + ' ';
   buff = crmForm.all.lastname.DataValue;
   if(buff != null) copyaddr += buff + '\r\n';
   buff = crmForm.all.jobtitle.DataValue;
   if(buff != null) copyaddr += buff + '\r\n';
   buff = crmForm.all.parentcustomerid.DataValue[0].name;
   if(buff != null) copyaddr += buff + '\r\n';
   buff = crmForm.all.address1_line1.DataValue;
   if(buff != null) copyaddr += buff + '\r\n';
   buff = crmForm.all.address1_line2.DataValue;
   if(buff != null) copyaddr += buff + '\r\n';
   buff = crmForm.all.address1_city.DataValue;
   if(buff != null) copyaddr += buff + ', ';
   buff = crmForm.all.address1_stateorprovince.DataValue;
   if(buff != null) copyaddr += buff + ' ';
   buff = crmForm.all.address1_postalcode.DataValue;
   if(buff != null) copyaddr += buff + '\r\n';
   buff = crmForm.all.address1_country.DataValue;
   if(buff != null) copyaddr += buff + '\r\n';
   buff = crmForm.all.telephone1.DataValue;
   if(buff != null) copyaddr += buff + '\r\n';
   window.clipboardData.setData('Text',copyaddr);
  }
  catch(e){
   alert(e.description);
  } 
  ">
  <Titles>
   <Title LCID="1033" Text="Copy Contact" />
  </Titles>
  <ToolTips>
   <ToolTip LCID="1033" Text="Copy Contact to Clipboard" />
  </ToolTips>
 </Button>
</ToolBar>
</Entity>