Exit loop if.
where to put this script? placed before End Loop? and what condition to put in the exit loop if a certain number of new records are created?
#script starts on layout for YourTable1, where user has selected a service option.
#YourTable1::YourField would be the field in your table that stores the number of service vists for that option.
Set Variable [$NumbTimes ; YourTable1::YourField ]
Go To Layout ["YourLayoutNameHere" ( YourTable2 ) ]
Set Variable [ $K ; value: $K + 1 ]
New Record Request
Insert some values to some field
Exit Loop If [ $K > $NumbTimes ]
Thank you PhilModJunk! You are very helpful!
A followup question. The script is working fine now, automatically add certain number of new records in another table. What if a user at first choose a wrong service and then he chooses the correct one. So in this case i need to delete the wrong new records in the other table. How to do this or any other ways to prevent this happen?
You will need a script to delete the added records. There is not enough detail here to tell you how to do that in detail. A find or Go To Related Records action would need to pull up a found set of the records that need to be deleted and then delete all records (name is misleading) can delete the records in the found set.
The alternative would require that you not create all of these records in the first place. Instead, you would create the records on an as needed basis later--with scripts/validation checks that use the number of services calls specified to make sure that the specified number of visits is not exceeded.