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
   Mobile 3.0.3 for Saleslogix v7.5.4, v8.0.0 & v8.1.0 is now available!
Saleslogix Mobile v3.0.3 is now available in the customer portals. This update addresses all issues int
Posted on Apr 14, 2014 by Scott Weber to SalesLogix Product Blog
 
   Editing Filters in Saleslogix Web Client 8.0
Is it possible to add or remove Saleslogix filters from the List view in Accounts?
Posted on Apr 08, 2014 by SalesLogix Support to SalesLogix Questions & Answers
 
   Creating a Unique Saleslogix table ID in a SQL Function
A couple of months ago Ryan Farley wrote an article about how to use a SQL stored procedure to create a S
Posted on Mar 25, 2014 by Kris Halsrud to Kris Halsrud's Blog
 
   Saleslogix Integration with Google - WOW!
Saleslogix will be releasing their Google Integration this month and from what I have seen, it is fantast
Posted on Mar 18, 2014 by Scott Weber to SalesLogix Product Blog
 
   Using a Test Plan
So you have approved the Statement of Work (SOW) for some modifications and are awaiting the delivery of
Posted on Mar 13, 2014 by George Jensen to George Jensen's 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