There are a number of ways to do this depending how you want your database to behave.
I'd have a portal on a layout that is based on the Work Orders table; with the portal set to show related records from the Time Logging table.
So, when you want to create a new Time Logging record, you'd go to your Work Order table and create a new record in the top row of the portal.
You'll need to ensure "Allow creation of records via this relationship" checkbox is checked under the Time Logging table in the relationship graph.
That would be a good solution, however the time logging can't be captured from a portal based on the work orders table, because this "time logging" information capture is meant to be mobil and speedy.
And to my understanding if I did it with your suggestion if I wanted to capture my time arrived and time departed; I would have to go to the "time arrived" field and type in the time, then go to the "time departed" field and type in the time, which takes a lot longer than just pressing a button that sets that field to the current time. And also, that way is a lot more prone to user error.
here is an example of my "time logging" layout in layout mode.
Buttons can perform scripts that use Set Field to enter the current time or the current timestamp into a specified field and this same script can create a new record when needed. Take a look at your Get Functions in FileMaker help. Get ( CurrentTime ) and Get ( CurrentTimeStamp ) are the specific functions you can use for this in this type of situation.
I have the buttons working correctly in my "time logging layout". As of right now I can create the record perfectly just the way I wanted. What I need to know is how do I link that record to a parent (work order) and a grandparent (company)
From the Work Orders layout (where you have to be in order to access the correct data to link the new record):
Set Variable [$WorkID ; value: Work Orders::__WorkPK ]
Go to Layout ["Time Logging" (Time Logging ) ]
Set Field [ Time Logging::_WorkFK ; $WorkID ]
Set Field [ ---> use this line to set the time or timestamp field with the current time or timestamp
Go to Layout [original layout ]
Either that, or use Phil_1986 suggested portal and put your buttons for setting the time in the row of that portal.
I will try that out right now, although I was looking to be able to link them from the child record (time logging). Is there not a way to do this? because my understanding from both of you is that the best way would be to create a "time logging" record from within the "work order" table.
The "time logging" layout is for an iPhone using filemaker go. I felt that the layout I created (the pic that i posted), was the most elegant solution for the user.
summary: can you link a child and parent from within the child, if so how?
AND AGAIN THANKS, THIS IS FRUSTRATING THE HELL OUT OF ME, NOT TO MENTION CONSUMING A LOOOOT OF TIME.
It's a matter of "context". If you are doing it from a layout based on TimeLogging, you'll need to have already captured the needed ID value to use to link to a parent record before the user get's to that layout. That might be as simple as a button on your Work Orders layout that set's the ID to a global variable before changing layouts or opening a new window to take the user to TimeLogging.
Then a script to create a new timeLogging record can also enter the value of that global variable. Or you can set the Fk field in TimeLogging to auto-enter the value of the global variable.
Shoot, that's why I haven't been able to accomplish what I've wanted to accomplish. Because it can't be done. I guess, I'll have to use one of ya'lls other solutions.
But Before I move on let me state my total desired outcome to see if you guys can point me in a different direction.
I was hoping to make the "time logging" layout screen the only screen available to the user, and the only screen they had to interact with.
Desire: I wanted them to click a button when they got in their car to go to location A, then click a button when they arrived at location A, and finally click a button when they left location A. Every time they clicked that button it would set the corresponding field to the current time (at the time of the click), and at the bottom there would be 2 unmodifiable fields showing the calculated result of time traveled and time worked. When they were ready to leave to another job they would create a new record (with a supplied "new record" button) and repeat the process.
Obstacle: However, this information on it's own isn't too useful if its not associated to a work order, so I realized I would have to put a field for them to let the program know what work order that time log belonged to, preferably a drop down list that contained all of the open work orders belonging to a certain company. Which made me realize that it would also need to be linked to its grandparent (company).
Potential Solution: The solution for this I thought would be to have field that would allow me to select one of the existing companies, and then a second field to select the open working orders for that company.
IS THIS IN ANYWAY POSSIBLE? or should I give up and go the other route (logging in times through a portal on the work orders layout.
If you set up a drop down or pop up for selecting the Work Order then problem is solved. That's the needed piece to link a new record to the correct parent. If you don't want to modify the current record by selecting a work order in this field, use a field with global storage and then your script for logging the time can copy the contents of the global field into the new time logging record to link it to the correct work order.
Yes, but what how do I set up that drop-down? I mean I know the steps to create a dropdown, but what content do I put in there?
From the "time log" perspective (looking at the screen from my first posted pic):
I have a field called ":Company_Name" and in it I have this value list
And a field called ":Work_Name" with this value list
I am at my ends wits and getting desperate.
Can you use show my pc and skype to explain this to me, I'll pay you something through paypal?
The first field should be __WorkPK, from Work Orders but you can't use the company name and show only it in the drop down. You aren't selecting a company, You are selecting a work order that is already linked to a company so when you select the work order you are also selecting the company. But you'll need some other field from Work Order as field 2 and it must store unique values so that your user can tell what work order they are selecting.
Another option would be a drop down to select the company if it works to then use a script to select the most recent work order for the selected company. But there's no way that I can tell whether or not that would work for your system.