Use Field options for this field to specify a unique values validation on the id field and then no script is needed to do this.
If the ID is only permitted once for any given record in the layout, you can use an auto-enter calculation on a new field that combines the Foreign Key used in the portal's relationship with the ID field that can only use a value once and then you can set up a unique values validation rule on that field.
There are also methods that prevent the user from selecting a value a second time in the first place.
See this demo file. It show three different ways to keep from putting the same value twice in the same portal: https://www.dropbox.com/s/oyir7cs0yxmbn6i/ManyToManywDemoWExtras.fp7
If you are using FileMaker 12, you can use the File menu to open this file and produce a converted copy that you can examine.
I Thank you very muxch for your help:)
It works perfectly.
And now , I passed to an other problem, I have a field A and Fiel B , in the same layout, Field A show record from tableA and field B show record frolm tableB. Some times , Field A cab bot show records when I add a new record, I wont to create a script that alllow me to replace recordof field A , where is empty , with records of field B.Thanks
Im using FM pro advanced 11
I can't make sense of what you describe. Also, using letters in place of the table names just makes it harder to track the key details.
What Relationship do you have between Table A and Table B? Do you have a Table A?
A record is made up of fields a field is not made up of records so "alllow me to replace recordof field A , where is empty , with records of field B" isn't possible. (It would be like replacing a car's door with a group of cars...)