I want a script to delete auto an account if expired day...
I have a layout that i add accounts...but i want a field that i put a day and if it passes this day to delete or deactivate this account automatically...
OK...but you know exactly what i must write in script...???
Thank you for your posts.
Create a script that does the following:
If [ Get ( AccountName ) = " <name of account> " ]
If [ Get ( CurrentDate ) > <the date field to compare> }
Delete Account [ <name of account> ]
Then, use this script as a Startup Script. When the user logs in, the Account name is checked. If it equals a specific account name, then compare today's date to see if it is greater than a specified date field (or constant). If so, then delete the account (or deactivate the account) and exit FileMaker Pro.
Let me know if you need clarification for any of the above steps.
...Hello, tell me something...it is necessary to create this script for each user, or one script for all user...???
very, very thanks...!!!
You will have to do this for each account you want to delete. The first line of the script could be:
If [ Get ( AccountName ) = " <first account name> " or Get ( AccountName ) = " <second account name> " or ......... ]
However, if you create temporary accounts that ll begin with the same few characters, and these are different from your other accounts, you could then look at the first few characters. For example,
If [ Left ( Get ( AccountName ) ; 4 ) = "Temp" ]
This looks at the first four characters, and if the AccountName starts with "Temp", then evaluate further, speeding up the process for permanent accounts.
Since there is going to be more than one evaluation, check to see if the AccountName does NOT equal "Temp", and then you can exit the script and focus on the evaluations.
If [ Left ( Get ( AccountName ) ; 4 ) ≠ "Temp" ]
Now, you'll have to evaluate for each account:
If [ Get ( AccountName ) = " <name of first account> " ]
If [ Get ( CurrentDate ) > ; <the date field to compare> ]
Delete Account [ <name of first account> ]
Else If [ Get ( AccountName ) = " <name of second account> " ]
If you are going to have a lot of temporary accounts, then you may want to put them into a table. You can then perform a find on the table for the AccountName, evaluate the date with today's date, and if true, then delete the account. Therefore, rather than having the above If... Else If ... End If, do the following:
Set Error Capture [ On ]
Set Variable [ $acc ; Get ( AccountName ) ]
Go to Layout [ <layout with table containing accounts> ]
Enter Find Mode 
Set Field [ Name ; $acc ]
Perform Find 
If [ Get ( FoundCount ) > 0 ]
If [ Get ( CurrentDate ) > ; <Date field> ]
Delete Account [ $acc ]
(at this point you can delete record, or set value of record to old date)
Retrieving data ...