B.Gordon Posted December 7, 2004 Posted December 7, 2004 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.
dkemme Posted December 7, 2004 Posted December 7, 2004 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.
Newbies PaulSbird Posted June 3, 2005 Newbies Posted June 3, 2005 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.
MoonShadow Posted June 3, 2005 Posted June 3, 2005 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.
Newbies PaulSbird Posted June 3, 2005 Newbies Posted June 3, 2005 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?
MoonShadow Posted June 3, 2005 Posted June 3, 2005 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?
MoonShadow Posted June 3, 2005 Posted June 3, 2005 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.
Newbies PaulSbird Posted June 3, 2005 Newbies Posted June 3, 2005 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.
Newbies PaulSbird Posted June 3, 2005 Newbies Posted June 3, 2005 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
-Queue- Posted June 3, 2005 Posted June 3, 2005 See here for a discussion and samples of the same technique in version 5.
-Queue- Posted June 3, 2005 Posted June 3, 2005 Maybe because the thread is almost 2 years old? Dunno. I give.
Newbies PaulSbird Posted June 9, 2005 Newbies Posted June 9, 2005 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
Recommended Posts
This topic is 7110 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