Modifying Copy-to-Clipboard

June 23, 2010

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….


June 23, 2010

As of SLX 7.5 LAN, you can now set the default comparison operator in lookups to be something other than “Starting With”.

Lookups which exist as controls on forms are the easiest to adapt, as they already have a DefaultLookupOption property exposed on their property page, so you can just change that in Architect.

For button lookups such as the “Account” button on the Account Detail view, that calls a FunctionLookupClick function, which is already using code to launch the lookup, via the Application.BasicFunctions.DoInvoke method. That would need to be rewritten to use the LookupItemWithConditionByID function instead.

For launches which are being done from menu/toolbar/navmenu items, instead of launching the lookup directly those would now need to run a new script, which in turn launches the lookup. For example, to launch the Account lookup with conditions from a menu item, and then have the Account record selected by the user in the lookup be loaded into SLX, you’d have the menu-item’s Action execute a VB Script (ActiveScript) containing the following code:

Sub Main

     Dim objLookup

     ' Ignore the blog-formatting line breaks here:
     Set objLookup = Application.BASICFunctions.LookupItem
        WithConditionByID("Account:Account", False, "", "",
        "", "", 2)

     If TypeName(objLookup) = "Link" then
          ' If type <> "Link" then the user Cancelled
          Application.BasicFunctions.DoInvoke "MainView", _
               "System:Account Details"
          Application.MainViews.ActiveView.CurrentID = objLookup.ID
          Set objLookup = Nothing
     End if

End Sub

You could save several steps by using ShowMainViewFromLookupWithConditionByID instead.

From the LAN Developer’s Guide .chm (not the PDF, where they aren’t given!), the enumerated constants which can be used for the last parameter of the LookupItemWithConditionByID function are:

loDefault = 0 (means Starting With for string fields and Equals for all other fields)
loStartingWith = 1
loLike = 2
loEquals = 3
loNotEquals = 4
loLTE = 5
loGTE = 6
loLT = 7
loGT = 8