December 7, 200421 yr I have a layout that contains a portal showing a list of related records. I want the user to invoke a script that makes a new related record based on the person whose data they are viewing. Easy enough if the portal is editable but the portal shoudl only be viewable. New records need to be input from a different layout with many more fields that I can display in the portal list. How do I script to go to the new layout and add a new record without it adding a new PERSON to the database. The new record command does not seem to be the answer as it creates a new record and a new blank person too... Simple problem I know... Any help would be great.
December 7, 200421 yr Create a script that goes to the layout with the table that is to have a new record, then New record. Now you need to enter into that new record the data that will make it related to previous table with a setfield ( Get ( ScriptParameter ) ). Then on your layout that has the portal, create a button named "New Record" that calls the above script, passing the data to make it a related record. I hope this helps get you in the right direction.
June 3, 200520 yr Newbies Would you post an example of your script? I''m new to filemaker and am having problems . Where dkemme says to go to the layout with the table, is it a layout of the master table or does the script go to the actual porta'sl table and open a layout there? I know it's something that I'm overlooking.
June 3, 200520 yr Scripts fire according to the table occurrence of the layout. To fire New Record in related, you must be ON a layout whose table occurrence is for the related table. However, many (most times) a new related record can be automatically created more easily by using the 'Allow Creation of Related'. Then there is no need to switch to a related layout or file at all. A simple Set Field [ related: any field but the key ] in the related file will create a new record for you (if one doesn't exist) and automatically insert the MainID into the related key. Ooops, you are vs. 6. The principle is exactly the same however, about creating related records via the relationship itself. Just change my words 'table' to file.
June 3, 200520 yr Newbies Thanks, that clears the layout/table part up! The Allow Creation is working good when I've a layout with a portal on it and I enter data into the portal. I have an issue similar to Bill's where I have a customer table, jobs table and invoice table. On the main customer layout I've a portal of the jobs table. I want a button which creates a new job. Explicitly the button should go to a layout, and enter a new job record with the exisintg customer number intact and an invoice portal. Is the answer to use a script to go to the jobs table, and create a new record?
June 3, 200520 yr The Allow Creation is working good when I've a layout with a portal on it and I enter data into the portal. If you use Set Field [ ] then you don't have to be on a table with a portal on it. But you DO need 'Allow Creation' on. Explicitly the button should go to a layout, and enter a new job record with the exisintg customer number intact and an invoice portal. I don't understand the invoice portal portion. Where do you want to end up when the script finishes?
June 3, 200520 yr I've hesitated giving specific script or solution because I'm unclear on what you have. However, the attachment Reed provided in this link will guarantee a new related record UNCONDITIONALLY via a Create table. If you always want a new related record, such as notes or lineitems, this method is great. It always creates a new related record when data is entered into the field. It can be placed above a portal for new entries. BUT, it can also happen flawlessly when the fields AREN'T on the layout by using Set Field [] and script. The idea for this to work is that the record doesn't already exist (depending upon a unique value). The demo Reed posted guarantees uniqueness by using a temp id. It blew my socks off!! Use 'Allow Creation' and never again have to leave a main layout ... just set CreateTable::AnyFieldButID. And never again have to worry about overwriting field data in related records because more than one already exists. Opps, you're version 6? Then you'll have to provide the unique determining factor on when to create a new record. God, it gets harder and harder to go back to 6-think.
June 3, 200520 yr Newbies I use the invoice portal to do line item of the job. The job table is there for initial and general job description. The invoice data entry is usually done after the job. (Carpet Cleaning Business). I ultimately want to end up back in the customer table layout. I've got it to work by running a script from the customer table, which in turn runs an external script that creates a new record with the correct customer field in the jobs table. I then placed a button on the jobs table layout to take me back to the customer layout. I think my confusion is navigating between tables and trying to make sure that it is transparent to the user.
June 3, 200520 yr Newbies Thanks a lot for your input. I think you got me headed in the right direction! I'm heading out for vacation so hopfully I'll retain this for the long weekend. When I get back I'll post a little more detailed info and any solutions I've come up with. Paul
June 9, 200520 yr Newbies Wanted to throw y'all a quick reply, cause the set field and your clarification on tables/layouts put me on the right path. So thanks and I'll post what I've done when i've done it ! Thanks again, Paul
Create an account or sign in to comment