Master Detail

by Todd Geist

Update: version 1.1.3 available 4/13/2013

UPDATE –  version 2.0 was released. Major changes. You can get it here.

Overview

Master Detail is module designed to make it easy for you to make Master Detail views on any FileMaker Table.

  • Works on any found set
  • Uses normal FileMaker sorting order.
  • Can handle 10s of thousands of records.
  • It works on FileMaker Go and FileMaker Pro

Dependancies

  • Modules
    • HyperList
  • Custom Functions
    • Triggers – for enabling and disabling Script Triggers

License

MIT License, see README

Overview Video

[vimeo id=”64247130″]

Installation Video

[vimeo id=”64243912″]

Download

Here it is…

version 1.1.2 4/13/2013

version 1.2 8/20/2013 Fixes from DevCon

Please see Master Detail 2.0 

56 responses to “Master Detail

  1. john renfrew says:

    Todd
    Is the MasterDetail dependant on the UUIDDecimal cf, is so it’s not listed anywhere…??

  2. dvareika says:

    Hi Todd,

    I have tried to implement Master Detail on a file of mine, but could not.
    At first I thought it was because I am using a separation model, but tried on the data file and no result at all.

    I did follow the instructions, tried the script and gives no errors.
    I did follow the steps thoroughly.

    The only thing I did not do (do not know how) if I have to do somethign about Custom Functions – Triggers.
    It does not seem to be any on the file to download.

    Thanks a lot for your help,

    Daniel

  3. dvareika says:

    The only place I did nothing is where there it says:
    “call the script “Get Values In Found Set ( Field Name )” in the Public
    give it the Name of the Field you wish to list”
    (Read Me | Hyperlist)

  4. dvareika says:

    If you could say how many triggers we should fix it would be of great help.
    I am finding only one in the field MasterDeatil_QuickFind

    • Todd Geist says:

      Please watch the movie and see if that helps you find what you missed.

      • dvareika says:

        Dear Todd,

        Thanks a lot, I was able to replicate in a subset of the db!
        The two things that I was doing wrong were:
        1. Not to import field “n” with data (serial numbers)
        2. Set the script triggers to the layout (understood with the video and was able to replicate).

        The rest I was doing just the same.

        Now I will try to replicate it with a full db.
        Do not know if it works with Separation Model or whether I have to keep those two fields (globals) on the layout with the data file.

        Once again, thank you!
        Impressive the work and style that you are promoting.

        Best Regards,

        Daniel

        • Todd Geist says:

          Hi Daniel,

          ah, yes the import, I can see how that could screw things up. I will get rid of the serial number there. Its not needed any more.

          It will work with the separation modal. It doesn’t care what file the table is in. 🙂

          Thanks 🙂

  5. […] Master Detail is mFM module that provides a master detail view for any table in your solution.  It uses the virtual list technique to reproduce the found set in a portal.  This lets you create any kind of layout that combines a list and the detail together on the same page.  Its very flexible and very powerful. […]

  6. mikeryan says:

    Thank you very much for generously sharing your fantastic work. Here’s the thing I’m struggling with now. For perspective, I’m an in-house, very part-time, developer for a group of technical workers. I’ve incorporated Master-Detail into a solution that leaves the standard FileMaker functionality exposed to the user. Unfortunately, there are a number of ways the found set can change leaving the Master list out of sync. It’s awfully jarring to the user when this happens. I’ve glanced at the code wondering what it would take to address these cases. Impressive stuff, way over my head! Any thoughts on where to go from here?

    • Todd Geist says:

      Hi Mike,

      Whenever the found set or sort order gets changed you need to run the script called Virtualize Found Set. That will keep things in sync. Typically I close the status area ( tool bar ) and keep it closed. I remove the menu options with a custom menu, and then control everything with scripting. That way I can always run that script after the found set or or sort order changes.

      Hope that helps

      Todd

      • mikeryan says:

        Todd, Thanks for the reply. “Virtualize Found Set” is just what I needed. I added a Refresh button and trained my users that whenever they do anything using built-in functionality that changes the found set, they can press the Refresh button to sync the list.

        -Mike

  7. LaRetta says:

    Hi Todd,

    I appreciate the clarity and simplicity of your modular approach to design. Thank you so much for providing these concepts to the FM community. I will certainly be taking advantage of this technique! 🙂

  8. Paul says:

    Todd, great Module. I have a question. Is it possible to link this to multiple tables in your solution? I’m figuring yes. Here is what I think I need to add. (Already have it linked to a table named sites) complete steps 2 and 3 and for step 5 have the base layout be the new table and then paste the layout from the masterdetails file. And then complete steps 6 and 7. Let me know if I’m off base.

    • Todd Geist says:

      Hi paul,

      Yes it is possible to link Master Detail to more then one table. Thats the beauty of it. It is completely decoupled from the underlying table. Looks like you have the steps right

      Thanks

      Todd

  9. Andy says:

    I have been playing around with this module a bit and so far it has been working great on the desktop OS’s. I tried bringing it into a solution I am building for go and am having some strange issues.

    The desktop version works as expected, the Go version is not showing the master list in the portal, also using the quick find brings you to the record that is expected but there is not anything that comes into the master list at any time.

    Do you know what the issue could be, or is there a difference you know of for the Go version as compared to the desktop version?

    • Todd Geist says:

      Hi Andy,

      I just tried the MasterDetail File on my iPad mini and it worked quite well. One of my goals when I designed MasterDetail was to get something that worked really well on the iPad with up to 5000 records. And as far as I can tell it does.

      Maybe try loading the MasterDetail file and see if that works for you

      Todd

      • Todd Geist says:

        However…. the built in Quick Find won’t work, because it doesn’t trigger the script Virtualize Found Set. You need to use the fake Quick Find that I added.

        HTH

        Todd

  10. Kevin says:

    Todd,

    Thanks for the great work and great site! Couple things I found that might need addressing. In the script, “Trigger: On Record Load” you have a step that goes to an object called “RecordsFound” – that object name isn’t on anything in the layout. This causes (at least under some circumstances in my testing) a flashing of the portal’s selected row when flipping records using the toolbar navigation. I found that if I had it select the “MasterDetailPrimaryID” instead (or add the object name of “RecordsFound” to something) it eliminated that problem.

    Also, on the conditional formatting of the portal rows. Would it make more sense to have the calculation set to: GetField ( GetLayoutObjectAttribute ( "MasterDetailPortal" ; "source" ) & "::ID" ) = GetLayoutObjectAttribute ( "MasterDetailPrimaryID" ; "content" ) rather than the GetField ( GetLayoutObjectAttribute ( "MasterDetailPortal" ; "source" ) & "::n" ) = Get ( RecordNumber )? I found that if the records get out of sync with the list for some reason (e.g. sorting and not re-running the virtualize function), this at least ensures that the correct record is highlighted in the portal. And it’s still in keeping with the modular abstract approach. Thoughts?

    Thanks again!

    Kevin

    • Todd Geist says:

      Hi Kevin,

      Is the flashing occurring on Windows? I don’t see it on My mac.

      I used to use that GoToObject to optionally hide the detail view if no records were found. Its cool but not necessary. We could get rid of that script step.

      As for the conditional formatting on the portal row…. That seems like it should work. And be less fragile. I’ll try that out.

      I really wish there was “after sort” trigger 🙂

      Thanks for the feedback!!!

      Todd

      • Kevin says:

        Todd,

        I’m on Mac as well, Mountain Lion, FMPA 12v4. The flashing only occurs when i use FileMaker’s toolbar and flip through the records. I simply downloaded the latest version, no changes, and started flipping the records and see it. It’s occurring for me during the onRecordLoad script trigger. If I step through with the debugger, the current portal row gets greyed (like when you click into any normal portal row, filemaker greys it) as soon as the script starts. I think this is because it gets left “in” the portal during the scroll script for the previous record. It gets fixed simply by going to another object in the onRecordLoad script after the scrolling is done. Not a big deal, just thought I’d mention it since I saw it.

        It would be nice to have an after sort trigger! There are always places where triggers would be nice. I went the route of custom menus and just updating the virtual list after each things that might cause the list to need updating (new record, delete, sorts, quick find, etc.). That seems to work. The custom formatting I mentioned seems to be working well for me, and it is less fragile.

        Thanks!

        Kevin

      • Kevin says:

        One more thing on the flashing, it takes flipping a few records in the same direction to see it sometimes.

  11. menerso says:

    If you use alphanumeric for your serial numbers in your table, you need to change the ID field Calculation to “Result is Text”

    That screwed me up for awhile.

    Cool system though

  12. Matthew P Fritz says:

    I like the idea behind MasterDetail but the download link doesn’t work. Where can I get the module?

  13. Simon Plint says:

    Todd, I have noticed that when I open MasterDetail.fmp12 into my copy of FileMaker 13 some of the Record menu commands are greyed out. Like as if there is an empty found set. Except the New menu command is greyed out too. As soon as you click into a field the menu commands are enabled but when you select a portal row in the sidebar they disappear again. Do you see this in FM13?

    BTW in the script “Trigger: On Record Load” you have a conditional script step to goto either the object “NoFoundSet” or “RecordsFound” but I can not fins these objects on the layout?

    Regards,
    Simon.

  14. Ben Miller says:

    Thanks for this Todd – very useful and the whole modules ideal is very interesting. I did have a couple of issues however. Firstly, I am using Data Separation – after some trial and error I seem to have this working as long as the MasterDetail table is in the UI file – it doesn’t seem to work properly of the MasterDetail table is in the data file. Secondly I was wondering what the purpose of the “secondary” conditional formatting in the portal is? The portal row of the current record is highlighted dark blue – which is useful, then another portal row is highlighted light blue – sometimes the last visible row, but not always (eg. find “john” and the 4th row is highlighted). Finally I was wondering why the “Find All” script, which needs to be connected to the “All” button of the quick find search field is in a Folder called “App – MasterDetail” which is outside the MasterDetail module folder. How does this fit into the Modular FileMaker concept?

    regards, and thanks
    Ben

    • Todd Geist says:

      The find all script may be very different from table to table. Or it might not be needed. It’s more of an example of how you might use MasterDetail, not part of Master Detail itself.

      Hope that helps.

      Todd

  15. Ben Miller says:

    opps – just realised that the so called “secondary” highlighting is in fact the active row state – sorry about that – I guess I want a way to end up on the row for the current record to avoid that.

  16. Ben Miller says:

    PS – and finally(!) – do you have a way to sort the portal?

    • Todd Geist says:

      You sort the portal by sorting the Found Set and then running the Virtualize Found Set script. Thats one of the cool things about Master Detail. The portal exactly matches the Found Set, including sort order

  17. Ben Miller says:

    Great – thanks. That make sense.

  18. Ben Miller says:

    Thank you – of course! I need to reverse my thinking – if you see what I mean!

  19. Ben Miller says:

    Thanks Todd – That makes sense. (Sorry I also “replied” to this below)

  20. Ben Miller says:

    Thanks Todd – Of course you are right. I need to reverse my thinking! (Sorry I also “replied” to this below)

  21. Denis says:

    This is great BUT there isn’t a way to really sort the master list in an effective way, unless I’m missing something.

  22. Denis says:

    My comment comes off as troll-ish but I mean simply as a seeming limitation of the implementation. But maybe I’m missing that this should be done in the Hyperlist beforehand. Off to Data View I go…

  23. Todd Geist says:

    Hi Dennis,

    One of the cool features of MasterDetail is that the sort order of the portal EXACTLY matches the sort order of the found Set. Sort the found set, and then Virtualize the Found Set, and your portal is sorted. It’s surprisingly fast.

    And there are no crazy portal sorting calcs or other tricks. Its just plane ole FileMaker 🙂

    Todd

  24. Gary Sprung says:

    Hi. What happened to the movie? It does not have a link and I cannot find it on Vimeo. Would love to watch that as this solution is confusing me.
    Thanks.

  25. Bruce Robertson says:

    Small spelling correction: “DEPENDANCIES” above should be DEPENDENCIES

  26. design tips says:

    Hi everyone, it’s my first pay a quick visit att this website, andd post iis ggenuinely fruitful for me,
    keep up plsting such posts.

  27. […] 2.0 has been released with a few new features.  MasterDetail 1.0 was a big hit and now it gets even better.  We added support for up to 5 fields in the found set, […]

  28. Simple says:

    Thank you for this great technique. I have a question regarding speed. I run this in my MacBook Air

    The click All took about 50 second to complete. Is this normal ? Looks a bit too long for me

    If I just want to collect the id ( version 1) , would it be faster and simpler to use the List (summary id) ?

    Cheers

  29. […] この部分を機能させることができたすぐ後に、このモデルによってできることがさらにあるということに気づきました。どこからでもレコードを作成するためにこのユニバーサルコンテキストを使用しているのであれば、同じようにこのモデルでどこからでも簡単にレコードを参照したり編集することができるのです。Master DetailやSelection PortalsはFileMakerで用いられる一般的な手法ですが、ユニバーサルコンテキストがそれらととても相性がいいということにほどなく気がつきました。 […]

  30. Tom says:

    I am trying to find a copy of Master Detail 1.0. I have a copy of MD 2.0, but want to compare the coding between the two. My hope is compare the differences for learning purposes. Where can I get a copy?

  31. Skip Jensen says:

    Hi Todd- First, I want to thank you for all of the amazing information you freely share with the Filemaker world. I am exploring bot Master Detail and Selector connector as I prepare to remodel a behemoth squid I created some years back. I have two things I would like to ask about. The first is that when I implement Master Detail in my solution, it behaves superficially different than in in the demo file in that when it scrolls to the current record in the portal, it also highlights the last record. It does not do this in the demo, and I have run them side by side with the data viewer chugging away, and for the life of me, I can’t find a difference between the two from a data standpoint. I thought I saw a post from someone else who had this issue, but I also cannot find it to save my sanity. I added a commit record step at the end of the scroll script, and the find all records script, and it works perfectly. I hate voodoo solutions to things, an would love to know what rookie mistake I am making.
    My second question is about Selector- Connect in regards to Master Detail. In your relationship graph, you show there are not supposed to be layouts for the MasterDetail and MastDetailRows tables, but yet there are layouts in the file. Could you explain what is supposed t be the case ? I am just trying to wrap my brain around the concept and this looks to be an exception to what I thought I understood.

    Thanks again for all of your hard work,

    Skip Jensen

  32. Todd Geist says:

    Hi Skip,

    You shouldn’t ever use layouts based on Selector or Connector. That’s the real no no.

    I’ll bet your Master Detail Portal has Active Row Highlighting on. So that the active portal row is highlighted by the style applied to the Portal.

    Such styles didn’t exist when I invented Master Detail 🙂

    Check it out

    Todd

Leave a Reply

Your email address will not be published. Required fields are marked *