Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Sunday, December 16, 2018 
 
Creating a New SalesLogix (v6) Table ID  
Description:  If you've been using SalesLogix version 6 at all, you've grown to love all the new features. But what about some of the simple tasks that have changed? This article will demonstrate how to create a new SalesLogix ID using the new SLX_DBIDS procedure.

Category:  SalesLogix VBScript Articles
Author:  Ryan Farley
Submitted:  11/15/2002
   
Stats: 
Article has been read 33063 times

Rating: - 5.0 out of 5 by 15 users
 

fiogf49gjkf0d
Creating a New SalesLogix (v6) Table ID

If you've been using SalesLogix version 6 at all, you've grown to love all the new features. But what about some of the simple tasks that have changed? This article will demonstrate how to create a new SalesLogix ID using the new SLX_DBIDS procedure.

The New SLX_DBIDS Procedure

SalesLogix 6 offers a cool new way to generate new IDs. No longer will you call DBCreateIDFor, now it comes in the form of a database stored procedure named "SLX_DBIDS". This is one of the many new internal procedures offered by the SalesLogix provider. It is not really a stored procedure. You will not find it looking at the database using SQL Enterprise Manager, it is a procedure that is intercepted and run within the provider to generate a new ID. Before we dive into it, let's take a look at it's syntax:

 SLX_DBIDS('<TableName>', <NumberToCreate>) 

As you can see, it takes two parameters (both are required).
  • TableName: This one is obvious. It is the table you wish to create the ID for. This value must be in single quotes.
  • NumberToCreate: This one is new. This parameter allows you to create multiple IDs at once. Say if you are doing an import and you know you have 1000 rows to create, you could pre-create the 1000 ID values and have them all ready to go, instead of creating them one at a time as you need them.

The way that this procedure is used is just the same as any other database procedure. You execute it in the provider. By that I mean that you would open up a connection and execute it via that connection. You cannot call it as a function inside your VBScript, it has to be done via ADO. We'll take a look at how to do this next.

Using the SLX_DBIDS Procedure

Using the SLX_DBIDS procedure is easy. Not as easy as calling the old DBCreateIDFor function, but once you do it once or twice you'll get the hang of it. I usually place it in a separate VBScript so I can reuse it as an Include Script whenever I need to create an ID.

Let's move on to see an example to create a single ID. In the example below, I have created a function to encapsulate the creation of a single ID for a table that is passed to the function as a parameter.

Private Function GetNewID(ByVal table)
Dim rs
Dim cn

    Set cn = Application.GetNewConnection
    Set rs = cn.Execute("slx_dbids('" & table & "', 1)")

    GetNewID = rs.Fields(0).Value & ""

    rs.Close
    Set rs = Nothing
    cn.Close
    Set cn = Nothing
End Function

Got that? It is pretty simple, but let's take a minute to examine what the function does. First, we need to get a connection. SalesLogix 6 provides with this cool new object called the "Application". The Application gives us access to grab a connection from the connection pool using the GetNewConnection method.

 Set cn = Application.GetNewConnection

We'll set our connection variable "cn" to reference this new connection. When you get a new connection from the pool using GetNewConnection, the connection is already connected (ie: open) to the SalesLogix database. All you need to do is use it and dispose of it when you're done.

Next we use the connection to execute the SLX_DBIDS procedure.

 Set rs = cn.Execute("slx_dbids('" & table & "', 1)")

What is happening here is this; we execute the procedure via the connection object and it returns to use a Recordset containing the ID that was created. If we chose to create multiple ID values, then the Recordset would be filled with the new ID values, each on a seperate row. Since we only chose to create a single ID value, we know there is only 1 row in the Recordset. Each row only contains 1 column which is the ID value.

We can access this column in the Recordset by it's index:

 GetNewID = rs.Fields(0).Value

or by the column name, which is "ID":

 GetNewID = rs.Fields("ID").Value


Wrapping it up

At first, it may seem like more work to create new ID values the "SalesLogix 6" way, but the payoff in the long run will be worth it. With the ability to create multiple ID values at once, you can speed up imports or long data operations. Since it is executed via the provider you can access it from outside applications, such as your own custom import or other applications, or from tools such as SQL DTS - without needing to log in via an API. By encapsulating the call to create an ID in a reusable function, you can use it as an Include Script to be able to call it in a single line of your VBScript code, just as you used to do with DBCreateIdFor.

Until next time, happy coding.
-Ryan


Updates

  • 12/2/2002 - Updated to to correct last phrase of article (I said LogSetGlobalID but meant DBCreateIdFor). Thanks to Ted Sturr for the catch.
  • 2/4/2003 - Updated code sample to show correct syntax (the single quotes were coming out as two consecutive single quotes in the HTML around the value passed to slx_dbids. Thanks to Rich Buckley for the catch.

 

About the Author

  Ryan Farley
(SalesLogix Business Partner)
Customer FX Corporation

fiogf49gjkf0d

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 Ryan's SalesLogix Mobile Seveloper Series
View Ryan's SalesLogix SData Developer Series
View Ryan's Git for the SalesLogix Developer series



View online profile for Ryan Farley
 

[ back to top] [ send to a friend]  

Rate This Article you must log-in to rate articles. [login here] 
 
Please log in to rate article.
 

Related Articles 
 - Creating SalesLogix Table ID Values - The Definitive Guide - Submitted by: Ryan Farley

 

Comments & Discussion you must log-in to add comments. [login here] 
 
Author Article Comments and Discussion
Ted Sturr



LogSetGlobalID or DBCreateIDFor?
Posted: 12/2/2002 9:51:03 AM
fiogf49gjkf0d
Love this board Ryan and looking forward to new articles. I was reading this article (I'm a little late diving into 6.0 going to do some testing starting this week) and your last sentence said "...just as you used to do with LogSetGlobalID", did you actually mean DBCreateIDFor?

Thanks again for all your help to the SalesLogix development community.

Ted
 
Ryan Farley

slxdeveloper.com Site Administrator
slxdeveloper.com Forum Top 10 Poster!

Nice catch Ted. Thanks.
Posted: 12/3/2002 12:02:40 AM
fiogf49gjkf0d
Doh! Thanks for catching that one Ted. Yes, I did mean DBCreateIDFor. I'll update the article to actually say what I mean!

Also, glad you like the site. I am working on a lot of new articles and hope to get the site filled with useful content. I hope it catches on and others will submit content too. There's a lot of features coming - including the option to "watch" the discussion for an article so you are notified when comments are added (I hate to have to keep checking back).

Anyway, thanks again.

-Ryan
 
Esteban
 

Re: Creating a New SalesLogix (v6) Table ID
Posted: 12/17/2004 9:43:43 AM
fiogf49gjkf0d
Hi,
I have to accept that the article help me a lot. Let me add some new features, just in case you want to linh slx data base using vb.net
I've been testing this smaal code to create a SLX ID using the slx_dbids function. Just copy and paste the code below:

Function CreateSlxID(ByVal Table As String, ByVal Q As Integer) As Data.OleDb.OleDbDataReader

Dim SlxConn As New OleDb.OleDbConnection
Dim cmd As New OleDb.OleDbCommand("slx_dbids('" & Table & " ', " & Q & ")", SlxConn)

SlxConn.ConnectionString = "Provider=SLXNetwork.1;User ID=dd;Data Source=ORCL;Extended Properties=SLX Server=sistemas07;ADDRESS=localhost;Type=ODBC;PORT=1706;Persist Security Info=False;Location=localhost"
SlxConn.Open()
CreateSlxID = cmd.ExecuteReader()
SlxConn = Nothing
End Function

Good Luck
Steve
 
 

       Visit the slxdeveloper.com Community Forums!
Not finding the information you need here? Try the forums! Get help from others in the community, share your expertise, get what you need from the slxdeveloper.com community. Go to the forums...
 



 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2018 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 12/16/2018 5:04:10 PM