How to handle Unique ID fields in SF


Author
Message
StrataFrame Team
S
StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
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.  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.
Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Trent,

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

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.

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
I must misunderstand what you are trying to do then because to my knowledge, VFP didn't do any of this for you.  We had to create this very same type of logic on our VFP apps.  They had auto-incrementing fields (VFP8 and later) but that was it.  SQL also has auto-incrementing fields, which is another choice.  Let me know if I am missing something Smile
Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Trent,

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

I will review your suggestions an I'm sure I will come up with a solution out of it.  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.

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
There are a number of ways to handle this.  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.  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.  But as far as unique values on non-pk fields, you could go down a lot of roads.  We have one instance in our medical software where we have a table that has several fields:

RecordType - Identifier for the table requesting a unique value (you can use an enum on the BO)
FieldName - The name of the field
LastValue - The last value that was handed out.  We update this field each time a new value is retrieved

You can then have a single BO that hands out unique values.  You can also create a shared method on teh BO so you do not have to create an instance:

Public Shared Function GetNextValue(Byval type as MyRecordTypes, Byval fieldName As String) As Integer
    '-- Create a temp instance of the BO
    Using temp As New MyUniqueValueBO()
        '-- Perform your query (usually a scalar method)
        '-- Update the BO with the most recent value retrieve
    End Using
End Function

Then in any BO which needs a unique value you would just call the GetNextValue method:

me.MyUniqueField = MyUniqueValueBO.GetNextValue(myType,"MyField")

Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi,

Some of my tables have unique id fields like Order Number, or Reference Number, etc. 

What would be the best way to handle the creation and maintenance of those type of fields? 

Is there any facility in SF for these fields?

Thanks!

Edhy Rijo

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search