Your script will only create a new record in SecondaryData if a related record does not already exist., but only if "allow creation of records via this relationship" is enabled for SecondaryData in the relationship linking these two tables.
PS: I try to never use script steps that start with "insert..." if I can use Set field to get the same result. Insert steps fail if the referenced field is not present on the current layout with access to the field permitted in field behavior settings. Set Field does not have these limitations.
Set Field [ SecondaryData::DateField ; Get ( CurrentDate ) ]
can take the place of Insert Current Date.
Ok, thanks for the tip using Set Field
About the creation of the record, I alredy have "allow creation of records" in the relationship.
The problem is that if I have some records like:
Master Record ID: 100
Related Records on Secondary Data for ID "100": 235, 279, 520
If I´m on the layout in record 100, my script works !
But If I create a "New Master Record", the script won't work, only if I go to another record and go back to the "New Master Record" and now this work perfect.
The "thing" that is not working is the password typing, no matter what I type, nothing happens!! It will not show ["Invalid"; "This is password protected"] or something.
I have to go to another record and go back to the new record to get it work.
Where is the bug??
What auto-enter settings do you have for "master record ID"? It sounds like you are either manually entering this value or it is an auto-entered serial number with the "on commit" option specified. Leaving the record and returning commits the record. So does clicking the background of the layout.
The "thing" that is not working is the password typing, no matter what I type, nothing happens!! It will not show
If this is FIlemaker 12, make sure that button one in SHow Custom dialog is specified to commit the data entered into the input field.
Ok, I do have an auto-entered serial number for Master Record.
With this info I could find the bug!! Something between allow creating records in tables Master and Global was not active.
Thanks a lot!!