Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Serial RecordID's


Recommended Posts

I'm developing a multi-relational db-solution where the 'main relations' depend on the field 'RecordID'. It is a simple auto-enter serial value, wich increases by 1. So far so good. The problem appears when I'm updating the files which the users use. Everytime I have to update the 'Next Serial Value' in the auto-enter box, and if I forget to do so, the relations (of course) will really crack.


Is there any way to automize this?

The consequenses of forgetting to update the values are a little to serious... smile.gif




Link to comment
Share on other sites

Hello Johan,

You can script the automation of the update process using the script step:


Set Next Serial Value [ ]


- which was introduced in FMP v5.5.


Then, so that your script can automatically determine the appropriate value to set (as a parameter within the above script step), you should set up a constant relationship (eg one based on a calc field with the formula specified as '1'), then use a formula along the lines of:


Max(ConstantRelationship::RecordID) + 1


The resulting step can then be simply added to the end of a script which performs the import, so that the whole process is fully automatic.


PS: If you are using v5.0 or earlier, then a similar outcome can be scripted with the use of the DialogMagic Plug-In (from NMI).

Link to comment
Share on other sites

Thanks alot.

I've implemented the script, and it works really well.


Another question thou:

Is it any idea at all to add a similar scriptstep to the 'add record' script, or would it work perfectly well by it self.

I would like to eliminate the possibility to have duplicate RecordID's as far as ever possible...


Thanks again.


PS Why are you using the self-relation when defining the scriptstep in the previous reply? Why can't you just use the recordID field as it is?

Link to comment
Share on other sites

Hi Johan,

To answer your second question first, the self relation ensures that the Max function addresses all the records, regardless of the sort order or the current location in the file - and in so doing, makes the procedure more reliable.


As regards inclusion of a Set Serial number into an add record script, I'm afraid it isn't a good idea.


For one thing, it isn't necessary, because FileMaker already handles the incrementing of serial numbers automatically, but for another, if the file were operating in multi-user mode, there would be a chance that two users would run the script simultaneously and the commands might cross over, with unpredictable results.


Occasionally, a procedure such as this is included in a 'delete record' script, to reduce the incidence of gaps in the contiguity of serial numbers. However in multiuser mode, again, there are risks attached, Ie if another user is creating a new record just when your script is resetting the serial number, you can end up with the processes crossing over and a duplicate number being issued, which rather defeates the purpose.


By contrast, the import script that you would run when installing a new version of the file would be designed to run on the host, presumably with only one user connected at the time, and in that context would be immune to problems of this kind.

Link to comment
Share on other sites

Thanks Ray.


You've really answered all my questions, and some more... smile.gif


I don't think I'll use the 'delete record' scriptstep thou. It wont be neccesary in my solution...


You're a really big help here on FileMaker Café, I very much appreciate the opportunity.



Link to comment
Share on other sites

  • Create New...

Important Information

Terms of Use