﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Implementing the Next ID Function</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 14:38:19 GMT</lastBuildDate><ttl>20</ttl><item><title>Implementing the Next ID Function</title><link>http://forum.strataframe.net/FindPost13087.aspx</link><description>When implementing the next ID for a non-primary key field, I would like to retrieve that incremental number during the save rather than at the SetDefaultValues (see &lt;A href="http://forum.strataframe.net/Topic12541-10-1.aspx"&gt;thread&lt;/A&gt;).&amp;nbsp; Here is what I did in my CustomersBO:&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;override&lt;/FONT&gt;&lt;FONT size=2&gt; MicroFour.StrataFrame.Data.&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;SaveUndoResult&lt;/FONT&gt;&lt;FONT size=2&gt; Save()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;this&lt;/FONT&gt;&lt;FONT size=2&gt;.CustID = &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;NextIDBO&lt;/FONT&gt;&lt;FONT size=2&gt;.GetNextID(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"CM"&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;base&lt;/FONT&gt;&lt;FONT size=2&gt;.Save();&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;Is that right?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;Then, within the NextIDBO, I am attempting to implement the function that will return the next ID based on the ID type passed in the argument.&amp;nbsp; I am running into a syntax hurdle.&amp;nbsp; For some reason, a public method in my NextIDBO cannot be seen by the CustomersBO.&amp;nbsp; The function looks like this (full implementation code stripped for simplicity):&lt;/FONT&gt;&lt;/P&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT size=2&gt; GetNextID(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; pRecordType)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT size=2&gt; mNextID = 0;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; mNextID;&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;Within this function I would run the appropriate stored procedure that returns a scalar value representing the next ID for the new record.&amp;nbsp; Perhaps I have not had enough coffee this morning.&amp;nbsp; What am I missing in the BOs so that the one can see the public method of the other?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;Thanks,&lt;BR&gt;Bill&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;</description><pubDate>Tue, 08 Jan 2008 13:59:10 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: Implementing the Next ID Function</title><link>http://forum.strataframe.net/FindPost13302.aspx</link><description>'Twas an easy fix.&amp;nbsp; The custid field has a default value of 0, so I just checked to see if the value was zero.&amp;nbsp; If true, then grab the next ID.&amp;nbsp; Whew!&amp;nbsp; Major crisis quickly melts into a very minor code change.&lt;/P&gt;&lt;P&gt;:P</description><pubDate>Tue, 08 Jan 2008 13:59:10 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: Implementing the Next ID Function</title><link>http://forum.strataframe.net/FindPost13301.aspx</link><description>[quote][b]Bill Cunnien (12/28/2007)[/b][hr]&lt;BR&gt;&lt;FONT color=#0000ff size=2&gt;private&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;FONT size=2&gt; CustomersBO_BeforeSave(MicroFour.StrataFrame.Data.&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;BeforeSaveUndoEventArgs&lt;/FONT&gt;&lt;FONT size=2&gt; e)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;NextIDBO&lt;/FONT&gt;&lt;FONT size=2&gt; mNextIDBO = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;NextIDBO&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;this&lt;/FONT&gt;&lt;FONT size=2&gt;.CustID = mNextIDBO.GetNextID(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"CM"&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;BR&gt;}&lt;BR&gt;&lt;/FONT&gt;[/quote]&lt;/P&gt;&lt;P&gt;:crying:&lt;/P&gt;&lt;P&gt;Alas!&amp;nbsp; This works even when editing an old customer record, too!!&amp;nbsp; Very scary!&amp;nbsp; I was in a demo to my manager when this reared its ugly head.&amp;nbsp; How do I check to make sure that I am actually in Add mode as opposed to Edit mode while in the BO?&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR&gt;Bill</description><pubDate>Tue, 08 Jan 2008 13:47:46 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: Implementing the Next ID Function</title><link>http://forum.strataframe.net/FindPost13197.aspx</link><description>Just to wrap this up and put a nice bow on it, I found that this approach to the GetNextID function worked best:&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT size=2&gt; GetNextID(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; pRecordType)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;SqlCommand&lt;/FONT&gt;&lt;FONT size=2&gt; mSQL = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;SqlCommand&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mSQL.CommandType = &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;CommandType&lt;/FONT&gt;&lt;FONT size=2&gt;.StoredProcedure;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mSQL.CommandText = &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"spx_GetNextID"&lt;/FONT&gt;&lt;FONT size=2&gt;;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mSQL.Parameters.Add(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"@pRecordType"&lt;/FONT&gt;&lt;FONT size=2&gt;, &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;SqlDbType&lt;/FONT&gt;&lt;FONT size=2&gt;.Char);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mSQL.Parameters[0].Value = pRecordType;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT size=2&gt; mNextID = (&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT size=2&gt;)ExecuteScalar(mSQL);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; mNextID;&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;The save function on the customer works like a charm, now!!&amp;nbsp; :w00t::w00t::w00t:&amp;nbsp; This is quite a simple approach to assigning an ID that auto-increments, yet is not a PK.&amp;nbsp; In addition, since I am assigning the ID immediately before the save (rather than on the Add()), the numbers aren't being gobbled up without cause.&amp;nbsp; I know one auditor who is going to like this.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;Wonderful framework, gents!&amp;nbsp; Excellent work.&amp;nbsp; It really has saved me a ton of hours.&amp;nbsp; I have actually converted months into days using this framework.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;Happy New Year!&lt;BR&gt;Bill&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Fri, 28 Dec 2007 16:03:49 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: Implementing the Next ID Function</title><link>http://forum.strataframe.net/FindPost13196.aspx</link><description>This is the method to run:&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;private&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;void&lt;/FONT&gt;&lt;FONT size=2&gt; CustomersBO_BeforeSave(MicroFour.StrataFrame.Data.&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;BeforeSaveUndoEventArgs&lt;/FONT&gt;&lt;FONT size=2&gt; e)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;NextIDBO&lt;/FONT&gt;&lt;FONT size=2&gt; mNextIDBO = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;NextIDBO&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;this&lt;/FONT&gt;&lt;FONT size=2&gt;.CustID = mNextIDBO.GetNextID(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"CM"&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;Now, I just need to get my ExecuteScalar syntax correct.&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Fri, 28 Dec 2007 15:52:17 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: Implementing the Next ID Function</title><link>http://forum.strataframe.net/FindPost13195.aspx</link><description>In my CustomersBO I have the following:&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;override&lt;/FONT&gt;&lt;FONT size=2&gt; MicroFour.StrataFrame.Data.&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;SaveUndoResult&lt;/FONT&gt;&lt;FONT size=2&gt; Save()&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;NextIDBO&lt;/FONT&gt;&lt;FONT size=2&gt; mNextIDBO = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;NextIDBO&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;this&lt;/FONT&gt;&lt;FONT size=2&gt;.CustID = mNextIDBO.GetNextID(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"CM"&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;base&lt;/FONT&gt;&lt;FONT size=2&gt;.Save();&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;The NextIDBO derives from my NextID table that stores the numbering for various entities.&amp;nbsp; The GetNextID function executes a scalar command that fires off a stored procedure that both grabs the appropriate value and then updates the NextID table.&amp;nbsp; The function returns this value to the CustID property as the new ID immediately before saving.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;This is not working.&amp;nbsp; The&amp;nbsp;Save()&amp;nbsp;override never fires.&amp;nbsp; Any thoughts?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;Thanks,&lt;BR&gt;Bill&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Fri, 28 Dec 2007 15:20:58 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: Implementing the Next ID Function</title><link>http://forum.strataframe.net/FindPost13111.aspx</link><description>[quote][b]Trent L. Taylor (12/20/2007)[/b][hr]In this case DO NOT use the AutoValues table and call a scalar method to get the MAX value of the PK (or whatever field that you need) and add one.&amp;nbsp; This way you NEVER have to use a transaction and you will always get a sequential number.[/quote]&lt;/P&gt;&lt;P&gt;I will be testing this save routine shortly.&amp;nbsp; I cannot use my PK fields (identity fields...by policy, not to be used for the record ID field).&amp;nbsp; The MAX&amp;nbsp;of a specific ID field is a good solution, but doesn't quite solve&amp;nbsp;all of my business policy issues.&amp;nbsp; It is possible for users to reset the numbering of a specific ID field.&amp;nbsp; I know, that sounds strange, but from a development standpoint, I don't care what they put in that field as long as it is unique (which I can trap).&amp;nbsp; I am simply providing a simple service by clicking the number up for them automatically.&amp;nbsp; For that reason, I will still need the NextID table to help me out.&amp;nbsp; If I work out the timing (set the number on save rather than on add), then transactions won't be necessary (I hope).&amp;nbsp; It would just be nice, I suppose.&lt;/P&gt;&lt;P&gt;Thanks a lot for the feedback, Trent!&amp;nbsp; Much appreciated!&lt;BR&gt;Bill</description><pubDate>Thu, 20 Dec 2007 15:40:51 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: Implementing the Next ID Function</title><link>http://forum.strataframe.net/FindPost13106.aspx</link><description>[quote]When a user clicks 'Add', is a new record created &lt;EM&gt;in the database&lt;/EM&gt;?[/quote]&lt;/P&gt;&lt;P&gt;No.&amp;nbsp; Only in the BO.&amp;nbsp; Anything that you do relating to .NET is going to be in a disconnected environment.&lt;/P&gt;&lt;P&gt;[quote]Or, is the new record actually created when the 'Save' button is clicked?&amp;nbsp;[/quote]&lt;/P&gt;&lt;P&gt;Yes, when the Save() of the BO is called is when the records are actually committed to the server.&lt;/P&gt;&lt;P&gt;[quote]however, there are several cases in which our auditors expect numeric integrity (no gaps, consistent, etc.).&amp;nbsp; [/quote]&lt;/P&gt;&lt;P&gt;That's fine.&amp;nbsp; In this case DO NOT use the AutoValues table and call a scalar method to get the MAX value of the PK (or whatever field that you need) and add one.&amp;nbsp; This way you NEVER have to use a transaction and you will always get a sequential number.</description><pubDate>Thu, 20 Dec 2007 14:35:41 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Implementing the Next ID Function</title><link>http://forum.strataframe.net/FindPost13104.aspx</link><description>Perhaps I need a bit of clarity.&amp;nbsp; When a user clicks 'Add', is a new record created &lt;EM&gt;in the database&lt;/EM&gt;?&amp;nbsp; Or, is the new record actually created when the 'Save' button is clicked?&amp;nbsp; &lt;/P&gt;&lt;P&gt;Also, we may just have a philosophical difference regarding these auto-incremental numbering.&amp;nbsp; In some cases, the number really does not matter (packing lists, work orders, etc.); however, there are several cases in which our auditors expect numeric integrity (no gaps, consistent, etc.).&amp;nbsp; For example, PO numbers, invoice numbers, sales order numbers, and so on.&amp;nbsp;&amp;nbsp;&amp;nbsp;So, in order to lessen the opportunity of burning numbers, I thought it would be best to assign the number at the moment of saving the record.&amp;nbsp; I can do away with the transaction part of things.&amp;nbsp; No biggee.&amp;nbsp; But, I will need to do what I can to preserve the numbering integrity.&lt;/P&gt;&lt;P&gt;I think I have the business object setup similar to what you have.&amp;nbsp; I am calling the GetNextID(string pRecordType) from the Save method on the form.&amp;nbsp; The business object for the NextID table will run the stored procedure to return the next value for that type and up the increment by one.&amp;nbsp; Just before the call to save, I set the ID field of the business object to the ID returned from the NextID table.&amp;nbsp; In theory, this should work fine, alas!&amp;nbsp; it does not.&amp;nbsp; I am sure that I am missing something quite simple. :unsure:&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR&gt;Bill</description><pubDate>Thu, 20 Dec 2007 14:09:46 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: Implementing the Next ID Function</title><link>http://forum.strataframe.net/FindPost13094.aspx</link><description>Bill,&lt;/P&gt;&lt;P&gt;I think that you may be making this more difficult that you need to.&amp;nbsp; We have the same need in our medical software to have fields auto-incremented on fields that are not the PK.&amp;nbsp; We created an AutoValues table and then created a shared class to wrap this so that we do not have to ever talk to the BO directly when assigning a value.&lt;/P&gt;&lt;P&gt;First of all, there is not any reason to put an autovalues table on a transaction.&amp;nbsp; This is just going to hand out a new ID (just like the Auto-Incrementing fields in SQL) to the table in which is requesting it.&amp;nbsp; If the record of the table that received the value does not commit for whatever reason, that is OK and that value will just never be used again.&amp;nbsp; &lt;/P&gt;&lt;P&gt;First, create your AutoValues table.&amp;nbsp; We use the same table for all of our auto-incrementing needs aside from the PK field.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sample Autovalues Table&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;av_pk - int - (Enum of the Type of Record)&lt;BR&gt;av_NextValue - int - (The next value that will be served up)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Sample AutoValues Class (Pseudo code)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Public Enum AutoValueType As Integer&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CustomerCode = 0&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PartsCode = 1&lt;BR&gt;End Enum&lt;BR&gt;&lt;BR&gt;Public Class AutoValues&lt;/P&gt;&lt;P&gt;Private Shared Function GetNextAutoValue(valueType As AutoValueType) As Integer&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- Create your scalar query method here as well as your update call to update the value.&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; '&amp;nbsp;&amp;nbsp;&amp;nbsp; You may have to create an INSERT as well if the record does not exist.&lt;BR&gt;End Function&lt;BR&gt;&lt;BR&gt;'-- Returns the next customer code&lt;BR&gt;Public Shared Function GetNextCustomerCode() As Integer&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return GetNextAutoValue(AutoValueType.CustomerCode)&lt;BR&gt;End Function&lt;/P&gt;&lt;P&gt;&lt;BR&gt;End Class&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Implementation within the BO&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Private Sub SetDefaultValues() Handles Me.SetDefaultValues&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.cs_Code = AutoValues.GetNextCustomerCode()&lt;BR&gt;End Sub&lt;/P&gt;&lt;P&gt;This turns everything into an object model access versus trying to re-code this everytime that you want to get another value.&amp;nbsp; Also it creates a single entry point.</description><pubDate>Thu, 20 Dec 2007 09:50:31 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: Implementing the Next ID Function</title><link>http://forum.strataframe.net/FindPost13092.aspx</link><description>I finally got back around to testing this.&amp;nbsp; It does not seem to work...at least, not from the transactional override.&amp;nbsp; I will try to override simply the Save method and see what happens.</description><pubDate>Wed, 19 Dec 2007 16:00:57 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: Implementing the Next ID Function</title><link>http://forum.strataframe.net/FindPost13088.aspx</link><description>The extra cup of coffee helped.&amp;nbsp; :w00t:&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;override&lt;/FONT&gt;&lt;FONT size=2&gt; MicroFour.StrataFrame.Data.&lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;SaveUndoResult&lt;/FONT&gt;&lt;FONT size=2&gt; Save(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;bool&lt;/FONT&gt;&lt;FONT size=2&gt; Transactional)&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;NextIDBO&lt;/FONT&gt;&lt;FONT size=2&gt; mNextIDBO = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#2b91af size=2&gt;NextIDBO&lt;/FONT&gt;&lt;FONT size=2&gt;();&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;this&lt;/FONT&gt;&lt;FONT size=2&gt;.CustID = mNextIDBO.GetNextID(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"CM"&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;base&lt;/FONT&gt;&lt;FONT size=2&gt;.Save(Transactional);&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;If there is a sproc involved in the retrieval of the ID, and I am wrapping the save in a transaction,&amp;nbsp;if&amp;nbsp;the save fails will the rollback involve the NextIDBO sproc call, too?&amp;nbsp; I assume that it will, but I'd like to be sure.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;Also, after playing with the syntax of the NextIDBO, I came up with this:&lt;/FONT&gt;&lt;/P&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT size=2&gt; GetNextID(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;string&lt;/FONT&gt;&lt;FONT size=2&gt; pRecordType)&lt;BR&gt;{&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int&lt;/FONT&gt;&lt;FONT size=2&gt; mNextID = (&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;int&lt;/FONT&gt;&lt;FONT size=2&gt;)ExecuteScalar(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"spx_GetNextID('"&lt;/FONT&gt;&lt;FONT size=2&gt; + pRecordType + &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;"')"&lt;/FONT&gt;&lt;FONT size=2&gt;);&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; mNextID;&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;I really thought there would be more to it.&amp;nbsp; Naturally, the spx_GetNextID references the sproc to retrieve and update the ID number.&amp;nbsp; Is this really all I have to do to make this incremental non-primary key field to update (and any others in the app, too)?&amp;nbsp; If so, I am blown away.&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;</description><pubDate>Wed, 19 Dec 2007 09:20:05 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item></channel></rss>