I've been asked a time or two in the Outlook2CRM forums about the possibilities of having Outlook2CRM match an e-mail with a SalesLogix conact using something other than the standard method of using the e-mail sender's address to locate a matching contact. This is certainly possible with Outlook2CRM and is an easy task.
Out of the box, the Outlook2CRM buttons all use the built-in methods of locating a matching contact from the sender's e-mail address and also make use of the Contact Match Dialog to prompt the user for how to match with the contact. The settings that tell the buttons to do this are all configurable in the Outlook2CRM Toolbar Editor. Please note, to change these properties you do need the Outlook2CRM Developer License.
There are a few different button properties that tell Outlook2CRM to automatically match up with a contact using the sender's e-mail address. They are the following:
- AutoContactMatch - This property tells Outlook2CRM to use the sender's e-mail address and automatically attempt to locate a matching contact in SalesLogix with the same e-mail address.
- UseContactMatchScreen - This property tells Outlook2CRM to display the Contact Match Dialog to the user. This dialog shows the user the match (if any) that the e-mail automatically matched with and presents other options for creating the missing contact or manually selecting a match.
- UseMatchScreenOnNoMatchOnly - This property goes hand-in-hand with the UseContactMatchScreen property and tells Outlook2CRM to only display the Contact Match Dialog if there was not an automatic matching contact found. If this property is set to True then if the AutoContactMatch yeilds a matching contact, the Contact Match Screen will not be displayed. It will only show if there was no matching contact.
Make sense? So, as you can see from those properties, you can easily turn off the out of the box contact matching for Outlook2CRM if you'd like.
Let's say that I wanted to have the "Ticket" button no longer match on the sender's e-mail address, but instead to parse an address from the message body and then proceed as normal. An easy enough task with Outlook2CRM. Let's take a look:
The Outlook2CM Addin Client API script has methods for setting the "matched" contact or account to use, Addin_SetAccount & Addin_SetContact. We can create our own custom scheme for determining what the matched records are and then set the appropriate records using those API methods. Then the other screens, such as the Outlook2CRM Ticket screen (that allows the user to select to create a new ticket, or update an existing one) will use the values we've set in the API.
Let's say our e-mail body looks like this:
Description: This is the description of the issue
We want to match on the e-mail value located in the body, not the sender's address. To do this, we will open the Toolbar Editor and change the following properties for the Ticket button (or create a new button with these properties):
AutoContactMatch = False
UseContactMatchScreen = False
Now, we'll open the script "Outlook2CRM Event - Create Ticket" (again, or create a new script instead) and add something along the lines of the following code:
lines = Split(Addin_Body, vbCrLf)
For i = LBound(lines) To UBound(lines)
If Left(LCase(lines(i)), 5) = "email" Then
email = Trim(Mid(lines(i), 7))
sql = "select firstname + ' ' + lastname as contactname, " & _
"contactid from contact where email like '" & email & "'"
Set rs = Application.GetNewConnection.Execute(sql)
If rs.RecordCount > 0 Then
'Lets set the matched contact
Addin_SetContact rs.Fields("contactid").Value, rs.Fields("contactname").Value & ""
retval = "success"
'No match, let's create a new contact/account
Addin_SetContactAction 2 'this tells the API we're going to create a contact *and* account
Application.BasicFunctions.DoInvoke "ActiveScript", "Outlook2CRM:Outlook2CRM Global - Create Contact Account"
retval = Application.BasicFunctions.InvokeResult
Set rs = Nothing
'Now continue on to create the ticket
If LCase(retval) = "success" Then Application.BasicFunctions.DoInvoke "Form", "Outlook2CRM:Outlook2CRM Dialog - Select Ticket Action"
That would solve it and we'd still get to use the other Outlook2CRM screens. Make sense?