macaroni Posted October 3, 2003 Posted October 3, 2003 I've seen a few examples where the parent file creates a related record in the child file by simply performing a set field of the foreign key in the child file. The relationship is Parent ID -> Parent ID (in child file) I tested it out and my question is how do you go about in creating multiple related records because I tried the script step of just "Set Field[Parent_Child::Parent ID, Parent ID] and this only seems to work when creating one related record. I ran it again and it didn't create another record. The child file's primary key is Child ID with an auto-enter serial no. What I have been doing is passing the foreign key through a global. I realize this is a very simple question and I'm still trying to learn all the neat features of FileMaker as I try to improve. Thanks...
ernst Posted October 3, 2003 Posted October 3, 2003 Hi Macaroni, It does not create a second record because a record already exists. If your script runs on a layout with a portal for the Parent_Child relation you could precede the Set Field command with a 'Goto Portal Row[Last] step to force a new record to be created every time you run the script. regards, Ernst.
bruceR Posted October 4, 2003 Posted October 4, 2003 macaroni said: I've seen a few examples where the parent file creates a related record in the child file by simply performing a set field of the foreign key in the child file. The relationship is Parent ID -> Parent ID (in child file) There is an interesting alternative I've seen discussed elsewhere. Create a global field gSelectedChildRecID. Create a relationship to the child file based on this ID. Set allow creation of related records to ON. The fascinating part of this relationship is that if the global field is EMPTY and you use a script or manual entry to place values in the related fields, a new record will be created and the global field will auto-populate with the new child record ID! This behavior is consistent and has been in effect since 3.0. So to create child records: set field [gSelectedChildRecID, textToNum("")] #now create the new record set field [CreateByGlobal::InvoiceID, InvoiceID] set field [CreateByGlobal::Qty, gQty] set field [CreateByGlobal::PartNum, gPartNum] exit record/request Of course if you do place a value in gSelectedChildRecID, then you can edit the selected record. You would do this by attaching a script to row in a portal for instance: set field [gSelectedChildRecID, Myportal::RecordID]
Recommended Posts
This topic is 7724 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