Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

One time script

Featured Replies

I have a script that deletes several found sets of records and then imports data from an external file. I need end users to run that script just once at the beginning of each calendar year. If it's run at anytime again after that it will delete relevant current data.

Is there any way to internally restrict or disable a script after it's been run once?

Thanks for any help or suggestions!

How are they to know when to run the script the following year?

Suggestion: Chuck the year into a global and then get the script to check what year it is at the beginning of the script. Obviously you will update the year at the end of it running.

  • Author

How are they to know when to run the script the following year?

An updated version of the solution is distributed at the beginning of every calendar year. The installation instructions would explain that the first step after installing the new version would be to run this particular script.

  • Author

Okay, I've simplified the script so it won't delete any data, but I still need it to import active employee information from the previous year's file when they receive the update version of the solution for the new year. This import should only be done once at the beginning of the year because employee info will get duplicated if the script is run more than once. I could explain that in the installation instructions, but I'm hoping to find a way to make it more "idiot-proof" so that the ability to run the import script multiple times is somehow restricted internally.

Make sense?

Since you have control of the files in this case, why not just have your script verify before running.

Add the script step If (use your own verification words), in this case I used your first name, and then once the script has done it's thing, use the Clear Step or Set Field to either clear the field, or set a new word like "Done".

HTH

Lee

ScriptToTestFirst.fp5.zip

  • Author

Since you have control of the files in this case, why not just have your script verify before running.

Thanks, Lee. Good idea.

They other round-about way I came up with was to create a field in the Employees table using the Get ( TotalRecordCount ) function. Then I added this to the script which runs each time the file is opened:

If [Employees::EmployeesRecordCount = 0]

Show Custom Dialog ["Import Employees"; "Would you like to import employee information from a previous year's file?"]

If [Get (LastMessageChoice = 2]

Exit Script

End If

Perform Script ["Import Active Employees"]

End If

Since the updated file they receive at the beginning of the year will not contain any Employee records, the script will ask them if they want to do the import the first time the file is opened, but once the table is populated with Employee records, the If statement will prevent the Import script from running again.

Not terribly elegant, but it gets the job done!

Your script would do the same thing (at least it reads that way), but I would be concerned of some data being entered prior to the script being run (i.e. my first instinct is to enter my name and information when I get Software). So, if an employee did this, your script might fail.

HTH

Lee

cool.gif

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.