UID ( )

Function stats

Average user rating
37
308
9999
Support
FileMaker 8.0 +
Date posted
13 May 2011
Last updated
26 March 2012
Version
Recursive function
No

Author Info
 Fabrice

79 functions

Average Rating 4.4

author_avatar



 

Function overview

Prototype

UID  ( _tableName )


Parameters

_tableName  


Description

Tags:  Uuid   Unique   Dev  

############# PARAMETERS ##########
_tableName    a string identifying the table

############# PURPOSE #############
Yet another UUID algorythm.
Obeys to the folowing principles

- unicity (extremely low probability of duplicate)
- compatiblity (50 char long)
- chronological sort
- performance (FileMaker does not consider the period as a word separator)
- information (a UID carries many information: table, date, time, record ID at creation, NIC...)
    to get, say the creation date, use GetValue ( Substitute ( ID ; "." ; ¶ ) ; 2 )
- readable

############# USE (IMPORTANT) #############
This function should be used in a auto-enter calculation for a TEXT field
Do not reevaluate checkbox must be unchecked (for record duplication)

Examples

Sample input

UID ( "CONTACT" )


Sample output

CONTACTX.0110512.163300.00020001.109add5b3fc0.4367

 

Function code

/* UID ( _tableName )

by Fabrice Nordmann, 1-more-thing
http://www.1-more-thing.com

############# HISTORY #############
v.1.1    May 2011
    added a digit in the year, and removed one in the random part (so chronological sort keeps working after 2100 :))
v.1        Dec 2010

############# PARAMETERS ##########
_tableName    a string identifying the table

############# PURPOSE #############
Yet another UUID algorythm.
Obeys to the folowing principles

- unicity (extremely low probability of duplicate)
- compatiblity (50 char long)
- chronological sort
- performance (FileMaker does not consider the period as a word separator)
- information (a UID carries many information: table, date, time, record ID at creation, NIC...)
    to get, say the creation date, use GetValue ( Substitute ( ID ; "." ; ¶ ) ; 2 )
- readable

############# USE (IMPORTANT) #############
This function should be used in a auto-enter calculation for a TEXT field
Do not reevaluate checkbox must be unchecked (for record duplication)

*/

Let ([ _ts = GetAsTimestamp ( Get ( CurrentHostTimeStamp )) ; _sep = "." ];

Left ( _tableName & "xxxxxxxxxxxxxx" ; 10 ) & _sep &    // Table 10
Right ( Year ( _ts ) ; 2 ) & Right ( 0 & Month ( _ts ) ; 2 ) & Right ( 0 & Day ( _ts ) ; 2 ) & _sep &   // Date 6
Right ( "00" & Hour ( _ts ) ; 2 ) & Right ( "00" & Minute ( _ts ) ; 2 ) & Right ( "00" & Seconds ( _ts ) ; 2 ) & _sep & // Time 6
Right ( "000000" & Get ( RecordID ) ; 6 ) & _sep &  // Record ID 6
Left ( Substitute ( GetValue ( Get ( SystemNICAddress ) ; 1 ) ; ":" ; "" ); 5 ) & _sep & // NIC 5
Middle ( Random ; 3 ; 5 )   // Random 5
)

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/308

    Prototype: UID( _tableName )
    Function Author: Fabrice (http://www.fmfunctions.com/mid/37)
    Last updated: 26 March 2012
    Version: 1.4

*/
// ===================================

 

 

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (32)
Date  (28)
XML  (27)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Interface  (15)
Layout  (15)
Text  (14)
Variables  (13)
Filter  (12)
Layout Objects  (11)
Design  (10)
Array  (8)