August 1, 200718 yr Could someone please take a look at the following script and see what's wrong: Open is a field in Parent that counts the nbr of “empty” child records in CHILD. I want the script to do the following things: If Open < 10 Go to CHILD table Create new record, put “A” in Source (in Child table) Repeat the above step until Open reaches 10 When Open reaches 10 Stop the loop and Exit. Expl: If Open = 6, when triggered the script should create 4 new records in CHILD. The script: IF [PARENT::Open < 10] Go to layout [CHILD] Loop NewRecord/Request SetField [CHILD::Source; “A”] Exit Loop IF [PARENT::Open = 10] End Loop End If The script is acting as if when records are created in child, either Open is not updated/or the script is not reading the value in Open and keeps creating records endlessly. When I abort the script a large nbr of records have been created and Open shows this large nbr.
August 1, 200718 yr What is the field definition for Open? If it's an aggregate calc, you may need to commit the records before the calc will update.
August 1, 200718 yr Author Open = Sum(CHILD::Source) I added CommitRecord before the ExitLoopIF step, no change the loop keeps looping. Edited August 1, 200718 yr by Guest
August 1, 200718 yr I see two problems: 1. Sum(CHILD::Source) does not work on text values. You might try count() instead. 2. The new Child records are missing a foreign key that would link them to a Parent record, so the reference to the parent "Open" field won't show a value anyway. You would need to store the parent key in a global and set that in each new record's foreign key.
Create an account or sign in to comment