Copying Dynamics CRM form values to the clipboard

For multiple records MS CRM options like mail merge and Excel exports are mighty handy.
For single record data export the Clipboard is more the way to go.

If you need the name and address of a certain account or contact … you want that to be directly available… in your CTRL-V.
If you want to print using a label printer… perhaps.
Exporting it to Excel or starting the Mail Merge may be a bit much to do… you for one record.

Start using this option… an ISV button “Copy name and address to clipboard” executing a JavaScript copying certain values to the clipboard.

OnLoad

CopyToClipboard =

    function () {

        // Construct the string you want on the clipboard.

        var sClipBoard = crmForm.all.firstname.DataValue + ” ” + crmForm.all.lastname.DataValue + “\n” +

                       crmForm.all.address1_line1.DataValue + “\n” +

                       crmForm.all.address1_city.DataValue + “, ” + crmForm.all.address1_stateorprovince.DataValue + ” ” + crmForm.all.address1_postalcode.DataValue;

        // Use/Create a input area

        var oClipBoard = document.getElementById(“ClipBoard”);

        if (oClipBoard == null) {

           oClipBoard = document.createElement(“input”);

           oClipBoard.setAttribute(“id”, “ClipBoard”);

           oClipBoard.setAttribute(“type”, “hidden”);

            document.getElementById(“crmForm”).appendChild(oClipBoard);

            }

        // Put in the clipboard string

        oCopyArea.innerText = sClipBoard;

        // Now copy to the string clipboard

        var oCopyText = oCopyArea.createTextRange();

        oCopyText.execCommand(“Copy”);

        };

 

Make the function available as an ISV button:

 
 

        <Entity name=”contact” >

          <ToolBar>

            <Button JavaScript=” CopyToClipboard ();” Icon=”/_imgs/ico_16_132.gif” ValidForCreate=”1″ ValidForUpdate=”1″ AvailableOffline=”true”>

              <Titles>

                <Title LCID=”1033″ Text=” Copy name and address to clipboard ” />

              </Titles>

              <ToolTips>

                <ToolTip LCID=”1033″ Text=” Copy name and address to clipboard ” />

              </ToolTips>

            </Button>

          </ToolBar>

        </Entity>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s