7 Replies Latest reply on Dec 7, 2011 7:15 AM by ccrumley

    How does FileMaker generate recid's?

    ccrumley

      Title

      How does FileMaker generate recid's?

      Post

      http://invdev.capitolabs.com/browserecord.php?-action=browse&-recid=123549

      this is an example of a URL and item from our web portal. 

      To begin the process of URL rewriting, I need to be able to read the URL,

      grab the recid,

      query the db to see if a row matches the recid, 

      then do some URL rewrite magic to get it to flip over so that 

      http://invdev.capitolabs.com/browserecord.php?-action=browse&-recid=123549 can become 

      http://invdev.capitolabs.com/browserecord.php/0-39-01487 (or whatever is applicable)

      Problem is, that recid is NOWHERE in our database, so I have no idea how to move forward here...

      How does FM associate the recid to a record in the database?

        • 1. Re: How does FileMaker generate recid's?
          philmodjunk

          RecordID is an internal serial number not stored in any field. Like an auto-entered serial number with the "on creation" option specified, the ID is assigned at the time the record is created. Unlike an auto-entered serial number field, you cannot modify the ID. Also unlike auto entered serial number fields, if you import the records (say into a back up copy or into a new version of the file), new ID numbers are assigned during the emport and you cannot prevent this.

          You can define a calcultion field with Get ( RecordID ) as its calculation if you need to find a record with a specific record ID.

          If you are reading this thread and are thinking "Why not use RecordID's for primary keys?" here is why you don't want to do that: Why Record ID's should not be used as Primary Keys in Filemaker Relationships.

          • 2. Re: How does FileMaker generate recid's?
            ccrumley

            I can see why they decided to stick with this functionality, but i'm still fuzzy as to how to map a record to it's recid.

            I need to be able to associate the two in a database/xml file/csv someway to begin the process of URL rewriting, but i'm at a loss as to how to match the two.

            here's a rough breakdown of where i'm at:

            we have a (custom web publishing generated) portal, and for SEO purposes a URL like http://invdev.capitolabs.com/browserecord.php?-action=browse&-recid=123549 is absolutely worthless to both the end user AND the search engines. 

            after a few additional steps, i can submit a sitemap to Google/Yahoo with clean and descriptive URL's that will take them to a listing in the site. to generate them is not any more difficult than exporting a .csv and concatenating to create some URL's like

            http://invdev.capitolabs.com/new/this-is-a-part-name-or-number

            so a user/search engine "clicks" that link, hits the site and gets flipped to an index.php that reads the incoming url (good example here), searches a db/csv/xml file for a match, and if found- accesses the data tied to that record- and flips instantly to the ugly URL (http://invdev.capitolabs.com/browserecord.php?-action=browse&-recid=123549) behind the scenes-- while the user still sees the pretty URL in the browser bar.

            problem is, if i can't match a recid to a record- this will never happen...

            have you seen anyone else attempt URL Rewriting with FileMaker?

            • 3. Re: How does FileMaker generate recid's?
              philmodjunk

              Define a calculation field set to return number with this expression:

              get ( RecordID )

              Now you can perform finds on your table to find records of a specific record ID by entering the specified number as criteria in a find or you can use this field in a relationship and use Go to Related records to find the specified record. This should work fine for recent searches of your database table for records of a specific ID. It will fail if this reference is stored in a URL and you deploy an updated copy of the databse where import records may have changed the record ID's.

              • 4. Re: How does FileMaker generate recid's?
                ccrumley

                that will work on the browserecord page for sure, and will return the record id-- but that doesn't solve any of my problems because if i want to get that records recid all i have to do is look at the URL in the browser bar.

                if i run that function you gave, all it will do is tell me the recid of the page i'm already on, and will tell me the same thing the URL already has...know what i mean?

                can you think of any way to extract the recid's for all items in the db?

                this is a snippet from browserecord.php that does what you recommended... think this can be extended to return a list of recid's?

                [code]

                $cgi->store('-recid', $record->getRecordId());
                $recid = $cgi->get('-recid');

                [/code]

                 

                thanks btw Phil

                • 5. Re: How does FileMaker generate recid's?
                  philmodjunk

                  Please note that I am not fluent in PHP so can only answer your question from the perspective of the database not the PHP code.

                  if i run that function you gave, all it will do is tell me the recid of the page i'm already on, and will tell me the same thing the URL already has...know what i mean?

                  This would be the record ID of a record, not a page. As i understand it, your page could have multiple records, each with a unique record ID.

                  You wanted to match the recordID in the URL to a record in the database correct?

                  Using the RecordID from the URL in a find or a relationship link would do that and this can be done by defining a calcualtion field in your database table to return the RecordID. Please note that I am not suggesting you use get (RecordID) in your php code, but to define a calculation field in the database for this. so that you can search for a record of this ID and then be able to reference the other data fields in this same record.

                   

                  • 6. Re: How does FileMaker generate recid's?
                    ccrumley

                    gotcha. i think...

                    so i can add a column to the database, and have it populate itself with a calculated record id... and then maybe reference it from a php script?

                    just so crazy it might work...

                    • 7. Re: How does FileMaker generate recid's?
                      ccrumley

                      UPDATE:

                      this does in fact solve the problem of associating the record to it's recid.

                      Great job Phil, thanks again.