2 Replies Latest reply on Jan 19, 2015 11:18 AM by CharlotteLasek

    Remove related info when unchecked



      Remove related info when unchecked


      Hi there,

      Thanks in advance to PhilModJunk for Loop through filters which got my script working this far. It relates Activities that the user chooses to an Event. I want to modify the script to UNrelate an Activity if it's un-checked. Here's my working script for the relating loop:

      Set Variable [$Event; value: EventDetails::__pkEventID]
      Set Variable [$ActList; value: EventDetails::checkbox_Activities]
      Set Variable [$K ; value: $K +1]
      Exit Loop if [$K > ValueCount ($ActList)]
      Freeze Window
      Go to Layout ["Activities for Event" (activities_EVENT)]
      Enter Find Mode []
      Set Field [activities_EVENT::__pkActivityID; GetValue ($ActList ; $K)]

      Set Error Capture [On]
      Perform Find []
      Set Field [activities_EVENT::_fkEventID ; $Event]

      End Loop
      Go to Layout [original layout]

      So, if an activity is NOT checked (or is UN-Checked) it won't be in the list ($ActList) and it won't be found with Perform Find. I need to also find related activities that are NOT in $ActList.

      I'm going to try a second loop that 1) finds all the related activities, 2) omits the $ActList results, and 3) removes the EventID – but maybe there's an easier way? Any help is much appreciated! 

        • 1. Re: Remove related info when unchecked

          I really, really wish that I had "Adventures in FileMaking #3 - Many to Many relationships" finished and ready for release.

          I'd set this up to replace the check box field with a portal that looked and acted like a set of check boxes, but clicking a "check box" in this portal is clicking a button that performs a script. That script would then add or delete records in a join table to "relate" or "unrelate" an activity to/from the current event. This would be a much simpler process than looping through all the selected values in your value list and definitely less complicated than identifying which values are NOT selected in order to do something with them.

          You can get a bit of an introduction to this method in the "check boxes with scroll bars" examples found in "Adventures in FileMaking #2 - Enhanced Value Selection", but these examples add/remove values from a list in a field where here, I'd create/delete records in a join table...

          • 2. Re: Remove related info when unchecked

            Thanks for the quick reply (as always). I'll check that out. I had initially tried doing something with a portal, but I didn't know how to get the as-yet-unrelated activities to show up. I tried making fields on each table called c_Activity (calc: "Activity") and filtering the portal to show those records if they were equal but it didn't work. I may not have related the tables… it still seems like that should work. I'll poke around some more. Thanks!