Tuesday, 31 August 2010

Copy Address to Clipboard in CRM 4.0

Ever need to copy the address from an Account in CRM 4.0 to the clipboard?

The following code placed in the ISV.config file will give you a button on the Account form copying the address to clipboard:

Copy_crmconsult

<Entities>
        <Entity name="account">
          <!-- The Account Tool Bar -->
          <ToolBar ValidForCreate="0" ValidForUpdate="1">
            <Button Icon="/_imgs/ico_18_debug.gif" JavaScript="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 + '\n';
            texttocopy += crmForm.all.address1_stateorprovince.DataValue + '  '  + crmForm.all.address1_postalcode.DataValue + '\n';
            window.clipboardData.setData('Text',texttocopy);
            }
            catch(e)
            {}"
            >
              <Titles>
                <Title LCID="1033" Text="Copy Address" />
              </Titles>
              <ToolTips>
                <ToolTip LCID="1033" Text="Click to Copy Account Address" />
              </ToolTips>
            </Button>
          </ToolBar>
        </Entity>

You could easily amend the code to run against other entities.

***Just a little warning……Only attempt the above if you’re confident editing this sort of system file. Always backup your file first. Don’t run with scissors. ***

0 comments:

Post a Comment