gaby78 Posted August 1, 2007 Posted August 1, 2007 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.
Ender Posted August 1, 2007 Posted August 1, 2007 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.
gaby78 Posted August 1, 2007 Author Posted August 1, 2007 (edited) Open = Sum(CHILD::Source) I added CommitRecord before the ExitLoopIF step, no change the loop keeps looping. Edited August 1, 2007 by Guest
Ender Posted August 1, 2007 Posted August 1, 2007 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.
Recommended Posts
This topic is 6325 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now