Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

The first time a particular script is executed each month, I want the serial number in to revert to 01. Not sure the best way to do this, any suggestions greatly appreciated. (Am in the process of rebuilding our databases to FM8, but in the meantime gotta get this working in FM6)

Thanks very much.

Posted

Of course, the first question I would ask is: why reset the serial number each month?

Most usually, such actions imply a need that is being met through a less-than-ideal solution. For example, people want to know how many orders have been made this month (or by this client, or for this salesman, etc.), which can be better managed and determined using relationships and calculated fields.

But if you really want to reset the value each month, try:

If[_gMonth <> Month(Get(CurrentDate))]

# The IF tests whether the reset has taken place this month

Set Next Serial Value [myfield; "1"]

Set Field[_gMonth = Month(Get(CurrentDate))

End If

David

Posted

Thanks for your replies, folks. To answer your question, T-Square, it's a YYMM## 'Job Number' calculated field that needs to reset each month. Was having a tough time getting the trailing ## (serial) digits to behave.

Thanks again--

Cheers

Posted

T-Square-- One thing I'm concerned about with your suggestion: won't the data in the global field _gMonth go away each time the file gets closed? Because data in globals don't get saved?

Posted

Well, Emo, the answer on whether globals persist is that "it depends." In a typical standalone situation, globals persist from session to session. Howver, according to FM help:

"If your file is shared, only the host's changes to global field data are saved. Changes are saved only when the file is closed."

So, you're right if you're hosting the file on a server and it doesn't get closed. But otherwise, it should be fine. I'm not sure where you got the idea that globals don't get saved.

But you don't really answer why you need this.

David

This topic is 6663 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.