"...then sorts all records by ID and goes to last record and sets next serial number to this ID plus 1" nothing wrong with that, but another way to do it, which I think is neater and less time-consuming as the file gets bigger, is to create a cartesian self-join for the table and have the last script step Reset Serial Values (That Field ; Max (SelfByConstant::ThatField ) + 1 )
This script, as written, is not compatible with server scheduled scripts. Import Records is very limited when run from a server schedule.
Here's a knowledge base article on the topic: http://help.filemaker.com/app/answers/detail/a_id/7035/kw/server%20import%20records
Note that from a server schedule, you can only export to and import form text type files such as a tab or csv file and it must be in a specific folder on the server in order to work.
We do this kind of script from a robot file to avoid these limitations. The robot file has a script set up in file options that runs when the file is opened. The script has just two lines:
Perform Script [//specify script in hosted file that needs to be run to move the records]
The robot file is set up to open its self with an account name/password that is also defined in the hosted file so when it opens, it is able to connect to the the hosted file as a clieint, run the script and then shut down.
We then use an OS based utility program to schedule that this file be opened at a specific time. Since we use Windows here, we use Windows Taskmanager to schedule that this robot file by "run" at a specified time. There are Mac OS equivalents to this scheduler that you can use on Mac systems.