Modifying Copy-to-Clipboard

As you probably know, the SalesLogix toolbar has a “Copy [Contact] Information to Clipboard” icon on it, which can be used to copy Account, Contact, or Opportunity information from the current entity to the Windows clipboard. In the Standard Toolbars plugin, that icon executes a compiled function, “Edit:CopyDataToClipboard”.

So how can you modify that functionality, to copy different/custom fields to the clipboard, or to copy information for a custom (MainView) entity?

It’s easy! Sneaky Sage developers, they’ve already provided a script with the code you’re looking for, in the SLX_CopyInfoToClipboard VB Script plugin; but it’s not being called by that icon! So all that you need to do is change the Action for the Standard Toolbar item to be “ActiveScript”, and set its Argument to the “System:SLX_CopyInfoToClipboard” script.

That script uses a Select Case statement to decide what information to retrieve:

With Application.MainViews.ActiveView
     Select Case .BaseTable
          Case "CONTACT" 'Contact  'DNL
               GetCurrentViewInfo = GetContactInfo(.CurrentID)
          Case "ACCOUNT" 'Account  'DNL
               GetCurrentViewInfo = GetAccountInfo(.CurrentID)
          Case "OPPORTUNITY" 'Opportunity  'DNL
               GetCurrentViewInfo = GetOpportunityInfo(.CurrentID)
     End Select
End With

To adapt that for your own custom entity/MainView, just add a Case in that Select statement, and write the “GetMyCaseInfo” procedure for it. Or, to add/remove fields from the actual ACO copying, just modify the SQL and the formatting in any of the three “Get…” functions, above.

If you wanted to do all that in a harder way, you could first create a new custom function, with a new Global Script event-handler, to launch the same (modified) field-copying code. This is useful as a learning exercise, just because it’s unusual to find all of the pieces and details for doing that sort of thing collected in a single place.

First, create the new custom function by running code like this in the Tools->Execute SQL… option in Workgroup Administrator:

VALUES ('MyEditCopyToClipboard', 1, 'Copy current screen data to
clipboard', 'MYCPY2CLPBD', 'F', 'Copy to Clipboard', NULL, 'Edit',

That ID value prolly needs to be unique….

Next, modify the Standard Toolbars plugin to call your new function instead of the old Edit:CopyDataToClipboard one, for the copy-to-clipboard toolbar item: After you set the Argument for that item to “Function”, your custom function should show up in the list of out-of-the-box SLX functions, under the “Edit” node.

Then, add a new Global Script, with an event-handler for the new function:

' Ignore the blog-formatting line break below:
Function OnBeforeFunctionExecute_MyEditCopyToClipboard_
   (functionNumber, functionName)


     OnBeforeFunctionExecute_MyEditCopyToClipboard = True
     ' Returns True to tell the system that it should not try to
     ' look for a further event handler for this event

End Function

Create a new VB Script, containing the MyCopyInfoToClipboard procedure (which just runs the code copied from the Main [etc.] subroutine of the SLX_CopyInfoToClipboard script, including the dependent Select Case stuff above) and add that as an Include file for the above Global Script.

Note that Global Scripts only load (and refresh) when you initially launch the SLX client, not when you just Ctrl+F5. One of the advantages of keeping the actual copy-to-clipboard code in a separate script (which is just called by the Global Script event-handler) is thus exactly that you can modify/debug it without having to re-launch the SLX client each time you make a change.

Of course, that’s not even an issue if you just do it the easy way, by launching the script directly from the toolbar icon.

Either way, note that the poorly-named .AsText property of the clipboard doesn’t simply convert whatever is in the clipboard to text, but is rather what you use to write text to the clipboard. In fact, that’s exactly how it’s used in the OTB SLX_CopyInfoToClipboard script.

If you want to do all this in an even harder way, there’s a very misleading posting on IT Toolbox which will get you pointed in exactly the wrong direction. That’s where I started with this, in needing to modify the copy-to-clipboard functionality for a client a few months ago….


Leave a Reply

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

You are commenting using your 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

%d bloggers like this: