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

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

Recommended Posts

Posted

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!

Posted

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.

Posted

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.

Posted

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?

Posted

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

Posted

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!

Posted

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

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