1 2 Previous Next 22 Replies Latest reply on Feb 10, 2012 10:43 AM by ahcho

    Creating new entries based on a portal

    ahcho

      Title

      Creating new entries based on a portal

      Post

      Hello!

      I think I might be FM'd out for today. But here's my current stumper.

      I have a portal pointing to a table called Job List, which is a list of all the employees and their associated job sites. I have another portal on a different layout that filters this list based on the user that is logged into the database. This portal only shows the relevant job sites.

      Each row of the portal has a create new record button that goes to a inspection layout. This layout is suppose to have job sites copied over from the portal but this only works for the first record in the portal. Creating records in the subsequent portal rows results in the same job site as the first row.

      Part of me thinks I need another table but I cannot think of what this table would do or look like.

      Aaron

        • 1. Re: Creating new entries based on a portal
          philmodjunk

          "I have a portal pointing to a table..."

          Oh what table is the layout based where you have this portal? What is the relationship that links the layout's table to the portal's table?

          Are employees associated with just one job site?

          What relationship do you have between your inspections table and the job sites table?

          Are you trying to copy the records or just link the new inspections record to the same set of Job sites records?

          • 2. Re: Creating new entries based on a portal
            ahcho

            Oh what table is the layout based where you have this portal? What is the relationship that links the layout's table to the portal's table?

            The only way I've been able to get the portal to fill up with results is using an layout based on the inspections table.

            Are employees associated with just one job site?

            No, employees can be related to more than one job site ("job list" table). It's one of those many-to-many tables.

            What relationship do you have between your inspections table and the job sites table?

            The relationship between the "job list" table and the inspections table is through the employee ID.

            Are you trying to copy the records or just link the new inspections record to the same set of Job sites records?

            I am trying to create a new inspection entry for every jobsite that the current user is working on based on the "job list" table.

            I've loaded a jpg of the relationships between the tables.

            • 3. Re: Creating new entries based on a portal
              philmodjunk

              The only way I've been able to get the portal to fill up with results is using an layout based on the inspections table.

              So with layout based on inspections, the portal lists all Job Sites for the employee assigned to the current inspection record. In fact, I'd expect to see the same portal of records if I based in on Employees. If you put a portal to Job List on the Sites layout, you'd get a list of Inspections and employees associated with that job site.

              I have another portal on a different layout that filters this list based on the user that is logged into the database.

              I don't see how that filter works. Since all the portal records in the portal on the inspections layout (the first layout) lists only job sites for a single employee, a filter would either leave all records in the portal or no records in the portal depending on whether the current user is the same person and the employee identified in the current inspections record or is a different person. That does not appear to make sense here. On what layout is this second layout based? Is this a portal to Job List also? Is there a portal filter expression? If so what is the expression?

              • 4. Re: Creating new entries based on a portal
                ahcho

                There is only one layout (I've attached a screenie).

                I blew away all the relationships and re-created the layout to clear my mind. Both points from your previous make sense after the re-create. The layout currently only shows entries related to the user that is logged in currently. If I add a filter to that portal, I get no records.

                But my problem still exists...if you look at the screenie, if I push the "a" button in the first row, I can create an new entry in the inspections table with the siteID being the entry 'super fake'. But if I push the "a" button on the second row, I still get a new entry with the siteID being 'super fake'.

                Now the button is pretty simple with the following script

                -----------------

                Go to Layout [ “inspections” (inspections) ]    

                New Record/Request    

                Set Field [ inspections::Start Time; Get ( CurrentTimeStamp ) ]    

                Set Field [ inspections::_kf_SiteID; Job List::_kf_SiteID ]    

                -----------------

                My old programming sense tells me there should be a loop but I have no idea how to implement it if that's the case.

                Aaron

                • 5. Re: Creating new entries based on a portal
                  philmodjunk

                  You need to capture the ID of the current portal row before chainging layouts.

                  When you execute:

                  Set Field [ inspections::_kf_SiteID; Job List::_kf_SiteID ] 

                  From the Inspections layout, you are referring to the first related Job List record and this is why you see Super Fake every time. (PS. ID fields are best defined as serial number fields--not name fields.)

                  I'm very suprised that you get ANY value entered into this new record by the set field since a new record is normally not related to any records due to empty key fields. By any chance do you have an auto-enter setting on a key field here that enters some kind of default value?

                  Here's the script you should use:

                  Set Variable [$SiteID ; value: Job List::_kf_SiteID ]
                  Go to Layout
                  [ “inspections” (inspections) ]   
                  New Record/Request   
                  Set Field
                  [ inspections::Start Time; Get ( CurrentTimeStamp ) ]   
                  Set Field
                  [ inspections::_kf_SiteID; $SiteID ]   

                  • 6. Re: Creating new entries based on a portal
                    ahcho

                    Thanks for the serial number name tip. 

                    The script worked and now the SiteID's are copying over correctly. I have one final question before going back to studying (learning filemaker > writing papers) which deals with the conditional formatting of the buttons. The formatting help from another post worked but when I implement it here, every button in the portal changes.

                    Now I understand why that is hapenning since the condtional formatting is tied to one variable (I was just setting the conditon to something in the inspections table). Apart from creating another table to track the changes, is there another way of doing it? Every way I've come up seems to fail at being able to tie each button to a specific siteID in the portal.

                    • 7. Re: Creating new entries based on a portal
                      philmodjunk

                      I'd need to know what your conditional formatting is expected to do before I can attempt to answer that. Wink

                      • 8. Re: Creating new entries based on a portal
                        ahcho

                        LOL. Durr on my part.

                        Basically I want to see which sites I've created inspection data for. I want to have a big red X on top of the buttons which changes when the user fills in data in the inspections layout. Once the user returns back to the checklist, that X should become a checkmark.

                        I am guessing that the X and checkmark will be text fields with conditional formatting but I am unsure of how to limit the switch to each individual button in each portal row.

                        • 9. Re: Creating new entries based on a portal
                          philmodjunk

                          They don't actually have to be fields. They can just be layout text. (Now I get a glimpse of what you had in mind in that other post...)

                          I need to understand the context here. On what layout (based on what table) would you want to see this indicator? If it's in a portal, explain the portal.

                          The X part is easy, that's a check for the existance of a related Inspection record. I don't quite picture what would cause the X to change to a checkmark. What does " Once the user returns back to the checklist," mean? I think you want a test to show that the inspection is complete and that would seem to require checking a status field on the Inspection record.

                          • 10. Re: Creating new entries based on a portal
                            ahcho

                            Ok. I've attached a screenie to this post. There's three windows in the screenie.

                            The screenie has the same portal as earlier, just cleaned up a bit to fit on an iphone screen. So pressing the "X" button on the first portal row will bring the user to the inspections screen (the middle screen) and the user will enter in the bags used of stuff (this page also has the geolocation stuff from several posts ago but the user doesn't need to see that).

                            Pressing the "End Check" button will bring the user back to the job list screen (the far left screen shot). I want the button from the first row to be changed to a check mark while the rest of the buttons remain as "X"'s until the data is filled out. The condition currently is ['Bags Used' > 0 ] for the checkmark to appear.

                            • 11. Re: Creating new entries based on a portal
                              philmodjunk

                              Nice screen shot, but doesn't fully answer my questions.

                              The layout in window one refers to what table? Inspections? Employees?

                              Does the portal refer to Job List?

                              On what table is the layout in the middle window based?

                              • 12. Re: Creating new entries based on a portal
                                ahcho

                                The layout in window 1 refers to Inspections. The portal is pulling from Job List.

                                The Middle window is based on the inspections table.

                                • 13. Re: Creating new entries based on a portal
                                  philmodjunk

                                  I wonder if your relationships will work for this. As designed, an employee can only have one inspection record. That doesn't seem like what you'd want to have here.

                                  • 14. Re: Creating new entries based on a portal
                                    ahcho

                                    I'm not sure I understand.

                                    I can create several entries in the inspection table for the same site, with the same user. If I log out and sign in as another user, I can create more entries that belong to the user that's logged in.

                                    1 2 Previous Next