Jump to content
Server Maintenance This Week. ×

How to reset a serial number in a field?


This topic is 3829 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi

 

I have an auto entry calculation field with value from the field "serial" which has serial increment

 

Right(Year(Get (CurrentDate));2) & "-" & Right("0"&Month(Get (CurrentDate));2) & Right(("000"&serial);4)

 

The output of which is:  yy-mm#### ; 13-110435 .... 13-110436 .........

 

How can I make calculation to reset the value "serial" in order to start from 1 at the beginning of every new month

 

Thanks 

Link to comment
Share on other sites

With what I have, just creating a new record (Ctrl n) will show up the calculated value in the field "Case_ID"

 

Would this be still possible with the script? 

 

And the other thing how to auto reset the value when the month changes?

Link to comment
Share on other sites

I think there are some assumptions here that are worth checking:

 

This script, attached to Case_ID with an OnObjectModify script trigger

Why would the user modify the Case_ID field?

 

Set Variable [$lastRecCalcMonth; Value:GetNthRecord (YourTable::Case_ID ; Get ( RecordNumber )-1)]

You are assuming that the most recent record is included in the current found set, and that the current sort order places it just before the current record.


Note also that the script will run (probably) while the new record is still uncommitted. A second user, creating a new record while this one is still uncommitted, will reset the serial again and create a duplicate.


See also:
http://fmforums.com/forum/topic/90112-calculation-help-with-serial-in-pk/?p=413582

Link to comment
Share on other sites

This topic is 3829 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.