![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
It is not good practice to use an editable field as the key field in a relationship. Your case of using components of the name as key fields is not good, because if some element of the name gets edited, the relationship will be broken. It is good practice to base relationships on automatically generated serial numbers that have no inherent significance to the user and will not be edited. For this purpose, you would define a serial number field in each table, and define the field so as to prevent modification of the number by the user. This serial number then should be the primary key field for relationships to that table. In each table that you want to relate to that table, you should put a number field to hold the key field number of the "master" table. A good naming convention is to use the field name in the form "kpContactID" for example as the primary key field in the Contact table, where "kp" signifies that it is a primary key. For the number field in the related table, use the convention "kfContactID" for example, to show that it is a "foreign key" and holds the number ContactID form the Contact table. The relationship is then based on a number that in itself has no significance to the user, and will not be edited. This means that the relationship will not break when you modify data in an editable field. Since you already have some number of records in each data table, and presumably have not defined the kp serial number key field in each table, you will need to define the kp serial number field, but for the moment allow the user to modify the number. Then go to a layout that shows the kp serial number field, go to the Browse mode, and do Records>>Show All records. Then click in kp serial field, and do Records>>Replace field Contents, select Serial Number, Initial Value 1, Increment 1, Update Serial Number in entry options, and click Replace. That will serialize the existing records and update the next value in the kp serial number field definition. Go to the field definition, check that the next value is correct, and then click the box to Prohibit modification of value during data entry. Do this for each of your data tables. Also define appropriate foreign key number fields in your tables. From your description, it sounds like you need a foreign key number field in the Bio table, to hold the value of the appropriate kpContactID. Call this field in the Bio table kfContactID. Assure that the relationships are correct as presently set up, based on names, so that the right bios are related to the each contact. You will now set the appropriate values in the kfContactID field for each Bio record. Go to a layout of the Bio table, that shows the field kfContactID. Go to the Browse mode. Do Records>>Show All records. Click in the field kfContactID. Do Records>>Replace Field Content, select Replace with calculated result, and specify the following formula: Contact::kpContactID which means you will put the value of kpContactID from the related Contact record in the kfContactID field of each Bio record. Click Replace. Verify that the values in the kfContactID field are correct for a sample of Bio records. Now go to File>>Define Database>>Relationships, and change the relationship between Contact and Bio to be Contact::kpContactID = Bio::kfContactID Delete all of the old Name parts of the relationship. This gets the relationship defined on a sound basis, a serial number that is unique to each contact, and that will not be subject to breaking because of editing contact or bio data. Set the relationship to allow creation of records in the Bio table via this relationship. You may also want to cause deletion of related Bio records when a Contact record is deleted. After you have verified that all is working OK, go to the layout of the Bio table that shows the field kfContactID, and either remove that field from the layout, for set the field behavior to prohibit entry in the Browse mode. That will prevent a user from inadvertently changing the value of kfContactID in the Bio table. In a layout of the Contact table, put a Portal to the related Bio table, and put appropriate fields from the Bio table in the portal. This will show existing related Bio records, and will allow you to create related Bio records directly from the Contact record. All the related Bio records for each contact should show up in the Portal, and you can go to the first empty row of the portal to create a new Bio record. The field kfContactID of the Bio table should NOT be one of the fields in the portal. The value of kfContactID will be automatically filled in when the new Bio record is created via the portal. I suggest you put a navigation pushbutton in the portal to Go to Related Record in the Bio table, and likewise a navigation pushbutton on the Bio layout to Got to Related Record in the Contact table. Another comment: The foregoing assumes you may have multiple Bios for one Contact. Perhaps this is not that case; maybe you really only have one Bio for each contact. In that case, why use a related table at all? Why not just put the Bio data directly in the Contact table? Bill Collins |
|
Hi, I'm new to Filemaker & this group so excuse me if I'm repeating old topics. I'm trying to finalize a solution for invoicing. Basically - a project has one customer a project can have many tasks & many invoices an invoice has many tasks I have tables for - customer project task invoice The project layout uses portals to set the customer, and add tasks (to a related task table). The tasks have a 'status' to indicate whether to invoice, not invoice or if they are processed. The invoice only displays tasks with a status of invoice. The problem I have is when I create an invoice (via a script that places the project id into the invoice) how do I set the 'status' fields of the related tasks to become processed. I want to use lookups so I can 'freeze' the data on the invoice but it seems like I'm duplicating most of my invoice & task tables. Is this the correct way to do it? The second problem I have is how to prevent duplicating invoices, how can I find if the invoice exists? Finally, should the project to invoice be a many to many relationship? I currently have a one to many relationship. Help is appreciated Drew Reece |
#3
| |||
| |||
|
#4
| |||
| |||
|
#5
| |||
| |||
|
#6
| |||
| |||
|
|
I think currently have what you suggested Grip. At the moment I have projects that have tasks assigned in a portal, some tasks won't be invoiced depending on their status. On the invoice I currently show related tasks that have the same project ID and a status of 'invoice'. Remi-Noel how can I filter the tasks that need to be invoiced from the ones that are not to be included? I presume I need to loop through the 'Invoiceable Tasks' setting the invoice ID field & task ID field in the details table. I seem to be approaching it from the perspective of projects first being assigned tasks, then an invoice being created for a group of tasks. thanks Drew Reece |
#7
| |||
| |||
|
#8
| |||
| |||
|
|
I create tasks via a relationship using the 'Project ID' via a portal |
|
Remi-Noel, At the moment I create tasks via a relationship using the 'Project ID' via a portal which seems easier than the 'Details Table' method you suggest. What would I gain by using the details table here? I want to add a button to process the tasks into an invoice, but my attempts keep failing. I was hoping to be able to change the status of the task when I have invoiced for it. My problem is how do I set a field 'Task Status' in multiple related records. I can get all the tasks with the same 'Project ID' & a 'Task Status' of invoice via a filter using the word 'invoice'. I'm certain its all possible using FileMaker but I must be coming from it at the wrong angle. Thanks for your help, I'll keep on with it. Drew Reece |
#9
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |