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)
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
If (lNum >= 65 And lNum <= 90) Then
lNum = lNum - 55
lNum = lNum * 36 ^ iPwr
lNumCmp = lNumCmp + lNum
CreatePrettyKey = "1-" & LTrim(CStr(lNumCmp))
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:
You simply combine the KeyPrefix with the KeySuffix and you have your complete PrettyKey which will be unique across remotes.