5 Replies Latest reply on Aug 19, 2010 2:39 PM by philmodjunk

    randomly displayed item

    m10muhammad

      Title

      randomly displayed item

      Post

      one table in my database is an inventory table with all of my machines. i am looking into hosting parts of this table online, and thus i am going though the process of designing the layouts i would want to be hosted online. the 'home page' layout is one such layout, and on it, i want to display a 'random' machine (i.e. with every page refresh, a different machine would be displayed on this page). is there any way to do this? please advise. thanks.

        • 1. Re: randomly displayed item
          philmodjunk

          There are several ways to do this using FileMaker's Random function.

          One method:

          Show All Records
          Go To Record/Request/page [No Dialog ; Random * get ( FoundCount ) + 1 ]

          • 2. Re: randomly displayed item
            m10muhammad

            I am thinking more along the lines of a 'box' in an already existing layout. The layout is based on a separate table than the one with the machines (this table, which is the 'home page', would show the search form which are global fields). Is there a way for certain fields from a record in the Machinery table to show up in a specific area of this layout? 

            • 3. Re: randomly displayed item
              philmodjunk

              Make your "box" a portal to the other table.

              Freeze Window
              Go to layout [//other layout based on table of records you want to select from]
              Show All Records
              Go To Record/Request/page [No Dialog ; Random * get ( FoundCount ) + 1 ]
              Set Variable [$$RandomID ; Value: OtherTable::PrimaryKey ]
              Go To Layout [Original Layout]
              Refresh Window [Flush cached join results ]

              Use that with a filtered portal (filemaker 11) or add one more step to use set field to put this variable's value in a field used in the portal's relationship.

              The filter relationships would look something like this:

              $$RandomID = OtherTable::PrimaryKey

              • 4. Re: randomly displayed item
                m10muhammad

                What would the relationship be defined as between the current table and the table with the records? 

                • 5. Re: randomly displayed item
                  philmodjunk

                  There are several options depending on what this table is based on.

                  Here's a simple one: Define a global field in the layout's table: MainTable::gRandomID

                  Then MainTable::gRandomID = EquipmentTable::IDfield

                  will work and you can replace the last line of the above script with Set Field [MainTable::gRandomID ; $$RandomID ] instead of filtering the portal. With this relationship you don't even need a portal you could just place the fields from EquipmentTable directly on the layout and everytime you perform the script, data from a different, randomly selected equipment will appear.

                  You also will no longer need the variable to be global so you can use $RandomID instead of $$RandomID.