4 Replies Latest reply on Jul 7, 2014 2:04 AM by BenOtto

    Extract / retrieve field / button name

    BenOtto

      Title

      Extract / retrieve field / button name

      Post

      Point of departure:

           Let's assume I have a 2-level hierarchy database, e.g. a set of boxes and each box has 100 slots (1:n match). Table 1 stores the boxes, table 2 the slots associated with each table.

           Table 1 ("Boxes") has a field storing the UIDs of the slots stored in table 2 ("Slots").

           Table "Slots" has:

           1) a field ("occupation") flagging, whether my slot is occupied or not.

           2) a name "name" field for more simple names (A1-J10).

           3) a reference field "boxUID" to the UID of the associated box.

      Goal:

           I would like to display my slots as a graphical solution that:

           1) shows which slots of a box are occupied and which not. If a slot is occupied the slot should be colored differently from the basic color (here in red vs light blue). So I want filemaker to check each slot associated with a box record and color the corresponding slot field according to its occupation state.

           2) allows me to click on one of the slots Filemaker and return the name (A1-J10) of this slot.

           3) is "inactivated" if it is occupied so I cannot perform step #2.

           Attached is an image of my current solution.

      My current construct:

           Each of the displayed slots is a button.

           a) Each button exits in a duplicate layered above each other. The upper button/field is colored in red and is displayed or hidden according to a calculated condition. The condition is a query that get the name of the slot (here is my current problem!!!) and checks the occupation state of the slot. What happens under the hood is: Pass the name (e.g. "A1") to the query function, go the "Slot" layout, search for the record matching the "boxUID" and the "name", and finally check the occupation state within this record. If the slot is occupied, I'll display the upper red field which will mask the lower one. Once the slot is free this upper entity is hidden and I get access to the button below.

           b) Each of the lower buttons invokes a function that just stores the name of the slot into some field / somewhere. 

      Problem:

           Now my current Problem is the following. My current solution requires that I pass the NAME (e.g. "A1") to the function/query in step a) for the hiding/displaying. Because the button has to know somehow which slot it represents. So I had to adjust each button for itself and hard-code the name of this button into the function. Similar with step b) I only can return the name of this button when I have hard-coded the name within the function.

           Which is ... a mess.

           First because it's really hard labour. Second because if I want to change something in the formulas I have to change the formula for each bloo***y single button. Third because "second" means: This is an accident waiting to happen. If I can't manage the equations/queries independent in one single master function, it is only a question of time until somewhere the code breaks or gets inconsistent.

      Thoughts:

           What I was hoping for was that I could "extract" the field/button name itself via some function and pass it to my query/output functions. Then I would just link my buttons to some central script or function that is managed within the scripts of functions and can be edited for all at once. Then I could just create one first "Slot-button" entity and just copy/paste it 100 times and give each button a distinct name such as "A1" or "D3" and so on. As soon as I change something, I'll just change it in my scripts or function sections but I don't have to touch the single buttons.

      Question:

           Unfortunately it seems there is no way read out the field name in Filemaker 13 Pro. Is that true?

           Is there some very simple and efficient way for my problem that I might have missed? Maybe I'm just doing it much too complicated.

            

           Thanks and cheers

            

           Ben

            

      Bildschirmfoto_2014-07-01_um_17.04.48.png

        • 1. Re: Extract / retrieve field / button name
          philmodjunk
               

                    Table 1 ("Boxes") has a field storing the UIDs of the slots stored in table 2 ("Slots").

               That appears backwards. I would set up a field in Slots that records the UID (primary key) of the Box record linked to it. That's the standard and simplest approach to setting up a 1 to many relationship. And I see that you do indeed have such a field listed as item # 3 in your post. That makes this field listing the UIDs apparently redundant.

               

                    I would like to display my slots as a graphical solution that shows which slots of a box are occupied and which not. If a slot is occupied the slot should be colored differently from the basic color (here in red vs light blue). So I want filemaker to check each slot associated with a box record and color the corresponding slot field according to its occupation state.

               This is essentially a "cross tab report" type layout. In FileMaker, your best bet is usually to set up a series of one row portals to Slots on your Boxes layout. I am assuming that each row in your image represents a different Box, though this need not be the case.

               You have two basic variations to evaluate on that scheme:

                 
          1.           When setting up each one row portal to slots, specify an Initial row of 1 for the first column, initial row 2, for the second column and so forth. This row of one row portals is often called a "horizontal portal".
          2.      
          3.           When setting up each one row portal to slots, specify a different portal filter for each column that limits the record shown to just one designated for that specific slot in the box.
          • 2. Re: Extract / retrieve field / button name
            BenOtto

                 Dear Phil,

                 I've been thinking about your suggestion today for a while now. Note, I'm no filemaker expert yet. But according to my understanding a classic cross tab portal would display one record per row with different fields of that record within the row.

                 I had a look at your discussion with Tiger1725 and your solution in thread

            http://forums.filemaker.com/posts/a753ac6247?commentId=266688#266688

                  

                 Now my image above should display 100 different records for the same box. So, again according to my understanding, what I would have to do is:

                 A) either insert 100 single portals with 100 different filters.

                 or 

                 B) 10 horizontally arranged portals where I set up a filter that selects all slots named "A1"-"A10" in the first column, "B1"-"B10" in the second and so on.

                 Am I correct?

                  

            • 3. Re: Extract / retrieve field / button name
              philmodjunk

                   Those are both possible implementations of this basic concept. Which is a better layout design will depend on how you need to interact with this layout.

                   There are also other options that are basically additional variations of this method that reduce the number of portals at the expense of adding additional fields.

              • 4. Re: Extract / retrieve field / button name
                BenOtto

                     Dear Phil,

                     perfect, I played around a little bit with your solutions and found one that does what I expect it to do.

                      

                     Thanks again.

                      

                     Ben