﻿<?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 » Issues  » How to handle Unique ID fields in SF</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 11:40:37 GMT</lastBuildDate><ttl>20</ttl><item><title>How to handle Unique ID fields in SF</title><link>http://forum.strataframe.net/FindPost12541.aspx</link><description>Hi,&lt;/P&gt;&lt;P&gt;Some of my tables have unique id fields like Order Number, or Reference Number, etc.&amp;nbsp; &lt;/P&gt;&lt;P&gt;What would be the best way to handle the creation and maintenance of those type of fields?&amp;nbsp; &lt;/P&gt;&lt;P&gt;Is there any facility in SF for these fields?&lt;/P&gt;&lt;P&gt;Thanks!</description><pubDate>Thu, 08 Nov 2007 13:53:27 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: How to handle Unique ID fields in SF</title><link>http://forum.strataframe.net/FindPost12569.aspx</link><description>We're looking into some of this functionality for the next version where we will allow meta-data about the field to be specified at the business object level.&amp;nbsp; But right now, that sort of functionality requires major plumbing and is more than just a quick patch, so I don't think it will make it into this major version.</description><pubDate>Thu, 08 Nov 2007 13:53:27 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: How to handle Unique ID fields in SF</title><link>http://forum.strataframe.net/FindPost12554.aspx</link><description>Hi Trent,&lt;P&gt;You are right, it was not part of VFP, but all VFP 3rd party frameworks including Visual ProMatrix the one I still use for my VFP projects have this kind of functionality for all type of fields (see picture attached).&lt;/P&gt;&lt;P&gt;This kind of feature could be added to the Business Object Mapper along with other information related to the field like Input Mask, Format, Tooltip, Error Message, etc.</description><pubDate>Wed, 07 Nov 2007 20:51:11 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: How to handle Unique ID fields in SF</title><link>http://forum.strataframe.net/FindPost12553.aspx</link><description>I must misunderstand what you are trying to do then because to my knowledge, VFP didn't do any of this for you.&amp;nbsp; We had to create this very same type of logic on our VFP apps.&amp;nbsp; They had auto-incrementing fields (VFP8 and later) but that was it.&amp;nbsp; SQL also has auto-incrementing fields, which is another choice.&amp;nbsp; Let me know if I am missing something :)</description><pubDate>Wed, 07 Nov 2007 19:44:09 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: How to handle Unique ID fields in SF</title><link>http://forum.strataframe.net/FindPost12550.aspx</link><description>Hi Trent,&lt;P&gt;Thanks a again for the sample code, much appreciated, even though in VFP I was already spoiled since this kind of feature is already part of the framework :crying:&lt;/P&gt;&lt;P&gt;I will review your suggestions an I'm sure I will come up with a solution out of it.&amp;nbsp; In my experience with VFP I have seen many of these implementations and was hopping to find something already available in SF to use, instead of coding it myself, which also improve my learning curve of the tools.</description><pubDate>Wed, 07 Nov 2007 18:50:22 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: How to handle Unique ID fields in SF</title><link>http://forum.strataframe.net/FindPost12542.aspx</link><description>There are a number of ways to handle this.&amp;nbsp; One option is to create a Scalar method or call a sproc that returns you the value from the server in the SetDefaultValues of the BO.&amp;nbsp; As you probably already know, StrataFrame will automatically manage primary key values and then update the child with the parents PK once it has been committed.&amp;nbsp; But as far as unique values on non-pk fields, you could go down a lot of roads.&amp;nbsp; We have one instance in our medical software where we have a table that has several fields:&lt;/P&gt;&lt;P&gt;RecordType - Identifier for the table requesting a unique value (you can use an enum on the BO)&lt;BR&gt;FieldName - The name of the field&lt;BR&gt;LastValue - The last value that was handed out.&amp;nbsp; We update this field each time a new value is retrieved&lt;/P&gt;&lt;P&gt;You can then have a single BO that hands out unique values.&amp;nbsp; You can also create a shared method on teh BO so you do not have to create an instance:&lt;/P&gt;&lt;P&gt;[codesnippet]Public Shared Function GetNextValue(Byval type as MyRecordTypes, Byval fieldName As String) As Integer&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- Create a temp instance of the BO&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Using temp As New MyUniqueValueBO()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- Perform your query (usually a scalar method)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- Update the BO with the most recent value retrieve&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Using&lt;BR&gt;End Function[/codesnippet]&lt;/P&gt;&lt;P&gt;Then in any BO which needs a unique value you would just call the GetNextValue method:&lt;/P&gt;&lt;P&gt;[codesnippet]me.MyUniqueField = MyUniqueValueBO.GetNextValue(myType,"MyField")[/codesnippet]</description><pubDate>Wed, 07 Nov 2007 17:35:04 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>