filemakernew

Unique Serial

Discussion created by filemakernew on Nov 18, 2013
Latest reply on Nov 18, 2013 by thong127

Hello All,

 

Im trying to edit a custom function for my serial for every month. I tried their suggestion but still i dont get any luck. Im trying to remove the "-" in between the numbers. they told me to remove this line

"year & "-" & month" and change it to "year & month". but when i tried its not giving me the serial anymore.

 

The custom function is

 

/*

MonthlySerial custom function

 

 

Author: Daniele Raybaudi

 

 

Format: MonthlySerial ( AEfield ; digit )

 

 

Result: text

 

 

parameters:

AEfield: text - the text field wich will hold the serial number; it must be setted as auto-enter, always evaluate

digit: number - the number of digit (#) that must increment by one and restart from one every new month

 

 

This custom function can be used for:

 

 

1) Autoenter a serial number that increments monthly

2) the format of the serial number is essentially: YY-MM###

3) the serial number may have how many digits (#) you choosed

 

 

The Auto-Enter field must be setted to always evaluate;

the custom function isn't recursive, so you can use it as a simple calc;

the custom function will work only with FMP8 and above.

 

 

 

 

05/23/2006

 

 

*/

Let([

year = Right ( "00" & Year ( Get ( CurrentDate ) ); 2 );

month = Right ( "00" & Month ( Get ( CurrentDate ) ); 2 );

lastId =GetNthRecord (AEfield; Get ( TotalRecordCount ) - 1);

lastMonth = Middle ( lastId; 4 ; 2 )

];

year & "-" & month

&

Case(

month ≠ lastMonth or Right ( lastId ; digit ) = 10^digit -1; Right ( 10^digit ; digit-1 ) & "1";

SerialIncrement ( Right ( lastId ; digit ) ; 1 )

)

)

 

Please help me.

 

Thank you.

 

Newbee

 

 


Outcomes