Creating a Pretty Key like the SalesLogix Ticket ID

A question that comes up every now and then is how to create a shorter, prettier key like the Ticket ID used in the support client. This is needed if programatically creating tickets, or if you need some unique number for some custom module such as a quote number. Using the SalesLogix table ID for something such as a quote ID results in a long hard to read value (and won’t win you many points with your customer). Creating a SalesLogix “Pretty Key” is easy, but there are some things to know about using these keys.

To create a pretty key in version 6.1 or earlier, you can use a function such as this:

Function CreatePrettyKey(ByVal sJobID)
Dim lNum
Dim sTmpNum
Dim i
Dim iPwr
Dim lNumCmp

    sTmpNum = Right(sJobID, 5)
    For i = 1 To 5
        iPwr = 5 - i
        lNum = Asc(UCase(Mid(sTmpNum, i, 1)))
        If (lNum >= 48 And lNum <= 57) Then
            lNum = lNum - 48
        Else
            If (lNum >= 65 And lNum <= 90) Then
            lNum = lNum - 55
            End If
        End If
        lNum = lNum * 36 ^ iPwr
        lNumCmp = lNumCmp + lNum
    Next
    CreatePrettyKey = "1-" & LTrim(CStr(lNumCmp))
End Function

Add that into a VBScript plugin and then include when needed. You pass to it the table ID for the record you’re creating it for. If you are creating a ticket you’d pass to it the table ID for your entry on the TICKET table. If you’re using it for something else you’d pass it the ID for that table. It will produce a pretty key based on that table ID. If your table ID is ABO1W000A234 then it will produce a pretty key value of 1-469264. I should also add that the hard-coded key prefix “1-“ is the same way this is done in the support client (which is part of the problem discussed next).

In v6.2 things change a little. The problem with the current way in 6.1 and prior is that there is no way to ensure uniqueness between remotes. In 6.2, the pretty key’s prefix (usually “1-”) is now unique per user in order to resolve this issue. In order to accomodate that change, new built-in functions were added to create the prefix and suffix parts of the key.

In SalesLogix 6.2 you use the following functions:

Application.BasicFunctions.GetPrettyKeyPrefix
Application.BasicFunctions.GetPrettyKeySuffix

You simply combine the KeyPrefix with the KeySuffix and you have your complete PrettyKey which will be unique across remotes.

ABOUT THE AUTHOR

Ryan Farley

Ryan Farley is the Director of Development for Customer FX and creator of slxdeveloper.com. He's been blogging regularly about SalesLogix, now Infor CRM, since 2001 and believes in sharing with the community. His new passion for CRM is Creatio, formerly bpm'online. He loves C#, Javascript, web development, open source, and Linux. He also loves his hobby as an amateur filmmaker.

1 Comment

  1. Hi Chris,

    You retrieve it from the table for the record you wish to create the PrettyKey for. Or if this is a new record you just create it normally using (assuming this is in a script) Application.BasicFunctions.GetIdFor(“mytable”)

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!