script field behaviour
how can i modify the behaviour of a field by script?
when a certain variable is = 1 I want to lock certain fields in a layout
Option 1: Use record level access control.
This locks the entire record so if you only want to lock specified fields in a given record, you have to restructure your tables as well as set up accounts and a record lock expression. What you do is split your current table into two parts linked in a 1 to 1 relationship. In one part of the table you keep the fields where you do not want to selectively lock the fields and in the new related table you place the fields that you want to lock in this manner.
With a one to one relationship and the "allow creation of records..." and "Delete" options specified for the related record, you can keep all the fields on one layout and the user doesn't see any obvious change in behavior due to splitting your table into two parts like this.
See "Editing record access privileges" in FileMaker Help and check out this particular sub section: "Entering a formula for limiting access on a record-by-record basis" for a detailed description of how to set up record level access control.
Option 2: Use script triggers that check for the locking condition when the field is entered.
The script uses an IF Step to check the value of your lock variable and uses go to field or go to object to put the focus somewhere else on your layout when the user attempts to enter a locked field. This requires setting up this method on every layout where you need it so this can be a less secure method than option 1.
Use a simple validation rule to reject all changes to the data in the locked field if the lock variable (or field) is set to 1. This still allows the user to enter the field and to attempt to make changes to it before throwing up the validation error so it's not as user friendly as Option 1, but does protect this field on all layouts from a single setting in Field Options so it is more secure than option 2.
Note that Options 2 and 3 can both be used on the same field or set of fields. Option 2 keeps it user friendly while Option 3 makes sure that no errors on your part have allowed a loop hole past your script triggers.
how can I lock certain fields for user1 and to be unlock for user2?
ok i think in the security paramaeters i can do this, no?
Yes, the lock expression can include a reference to the user's account name or privilege set name. (There are get functions for each.) This can be matched to a value in a field in the record to control access.
Retrieving data ...