Login / Register  search  syndication  about

          Ryan Farley's Blog

Ryan Farley on .NET Development with a focus on CRM Development for SalesLogix

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.

What's This?
  
Bookmark and Share

About Ryan Farley

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

View the SalesLogix Mobile Seveloper Series
View the SalesLogix SData Developer Series
View the Git for the SalesLogix Developer series



Related Content
   Saleslogix Xbar update coming soon
Scheduled to be released 8/29/2014 Features in Update •Installation improvements •Enterp
Posted on Aug 21, 2014 by Scott Weber to SalesLogix Product Blog
 
   How do you add a parameter for File Attachment Size and Timeout in Saleslogix 8.1?
Question: Is it possible to set a parameter for file attachment size and timeout in Salelogix? If
Posted on Aug 07, 2014 by Dale Richter to SalesLogix Questions & Answers
 
   Fixing Duplicate Saleslogix FieldIndex Values in the SECTABLEDEFS
I had to fix a client's SECTABLEDEFS table that contained duplicate FieldIndex values.  FieldInd
Posted on Aug 07, 2014 by Kris Halsrud to Kris Halsrud's Blog
 
   Saleslogix XBar Installation
When installing the new XBar application I found the instructions a little vague so I thought I would pas
Posted on Jul 18, 2014 by Mark Duthoy to SalesLogix Support
 
   "Saleslogix’s affordable pricing and usability allow the product to rise above competitors in the space" - Info-Tech Research Group, Inc.
"SalesLogix’s affordable pricing and usability allow the product to rise above competitors in the sp
Posted on Jul 14, 2014 by Scott Weber to SalesLogix Product Blog
 
Comments

 

Chris Donaldson said:

I am having a brain dead day....where do I find the tableID?

Thanks...cd

September 11, 2009 2:22 PM
 

Ryan Farley said:

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")

September 11, 2009 3:16 PM
 

Ryan Farley's Blog said:

Some entities in SalesLogix, such as Tickets, use a &quot;pretty key&quot; as an easier to use value to reference the record. These pretty keys take a SalesLogix table ID value and then create a value like 000-00-1234. If you are creating an external

February 28, 2014 5:00 PM

Leave a Comment

(required)  
(optional)
(required)  
Add
All contents Copyright © 2014 Customer FX Corporation
Customer FX Corporation
2324 University Avenue West, Suite 115
Saint Paul, Minnesota 55114
Tel: 800.728.5783

  Follow @CustomerFX on twitter
Follow the best news, tips, and articles
  Subscribe to Customer FX on youtube
Watch SalesLogix tutorial videos from Customer FX
Login / Register