7 Replies Latest reply on Nov 15, 2013 10:59 PM by inalaop

    need advice; regarding flagged record badgecount

    inalaop

      I made a 'reminder' flag system; for an individual record I can set a future 'reminder date'. When that date is overdue (less then today's date), I have a script (zReminderAllert) that sets a text of "RA" on a record to flag it as a reminder allert. I use this in list view (as seen). At the top header I have a 'Reminder Allerts' box and what I want is an updated total of ALL reminders in the whole database (whether or not all records are shown or there is a smaller found set). My system works great except for one thing; as soon as I do a search for some record or records, and the found set changes, the Reminder total (badgecount) changes. This would be expected from how I set this up since I am using a field summary function to total these. However I want to keep this value from changing when the found set changes (I do want it to update if I clear or delete a reminder date). For example, the #2 badgecount you see is the total reminder allerts for the total database. If I search for a record and there is one in the found set, the total changes to zero.

      I am probably not setting this up right. Is there a simple fix to this? I would prefer not to have to set up a self-join or complicated filtered relationship for this to work. Do I need some type of global setting ?

       

      Any advice would be appreciated.

       

      Here are my fields, and some pictures if they show up:

       

      zReminderDate

      reminder date input field

       

      zReminderAllert [calc; unstored]

      Case (

      not IsEmpty (zReminderDate) and zReminderDate ≤ Get(CurrentDate); "RA"; not IsEmpty (zReminderDate) and zReminderDate ≥ Get(CurrentDate); "*"

      )

       

      zReminder_1or0_Flag

      Case (

      not IsEmpty (zReminderDate) and zReminderDate ≤ Get(CurrentDate); 1; 0

      )

       

      zReminderTotalBadgeCount (summary)

        • 1. Re: need advice; regarding flagged record badgecount
          davehob

          Hello. There are various ways to achieve this (as usual with FM!).  If you really want to avoid new relationships, you could go for a global variable ($$REMINDERCOUNT?), populated at startup (via a Find script), and maintained each time you add or remove a reminder.  You can then display that variable wherever you want it, via Insert, Merge variable.  The value won't change until you change it.

           

          Dave.

          • 2. Re: need advice; regarding flagged record badgecount
            inalaop

            Hi Dave,

            I did set up the global variable at startup with this script on a script trigger onfirstwindowopen;

            perform find (finds all overdue reminders)

            set variable [$$Badge; value:get(foundcount)]

            exit script []

             

            I then put the merge variable <<$$Badge>> on the layout and reopened the database and it did work to show the "2" overdue reminders. However this number does not subsequently update. For example, I then set a new reminder to be overdue and so the total should be 3 but the <<$$Badge>> still read "2". I want a way to have this number also constantly update.

             

            Any other techniques you can recommend?  If I need to add a table occurrence or filtered relationship, I can do that but I just don't have much experience with that (I'm a nubie). My database is a sample project I am working on to learn filemaker pro so no need to worry about messing it up; I also make backups.

             

            Thanks again

             

            Derrick

            • 3. Re: need advice; regarding flagged record badgecount
              keywords

              The most obvious way, it seems to me, would be to rerun your set global variable script each time something occurs which means the global variable's value may change.

              • 4. Re: need advice; regarding flagged record badgecount
                davehob

                Yes, that's what I meant in the first place - sorry if that wasn't clear.

                 

                But, if you want to try using a relationship, you'll benefit in the long run, because there's less (i.e. no) updating by you.  Again, lots of ways of doing it, but probably the most straightforward:

                 

                - A global field (e.g. "TODAY"), set to today's date on startup. (You haven't said what your table structure is, but I get the impression it's a single table?   If not, this field goes in the table that hold reminder details.)

                 

                - A self-join - let's call the new Table Occurrence "RemindersDue".  This is related to the main table occurrence with a relationship thus: "TODAY ≥ RemindersDue::reminderDate"

                 

                - Another global field, "ALERTCOUNT" which basically counts the number of recs via the self-join - i.e. Count ( RemindersDue::id ) (where id is the always-present key field).

                 

                You can now display ALERTCOUNT on the main layout - doing it this way, the ALERT COUNT will always be up to date, so less margin for error, no scripted updating, etc.

                 

                Dave.

                • 5. Re: need advice; regarding flagged record badgecount
                  inalaop

                  Thanks for the info. I think this will work and i will try it. I tried something similar recently but i did not have it set up correctly; i did not have the global 'todaydate' field which is probably why.

                   

                  Derrick

                  • 6. Re: need advice; regarding flagged record badgecount
                    keywords

                    Glad you got there Derrick. It is always good to learn! I think you should award the Correct Answer tag to Dave rather than yourself though, so that he gets the kudos.

                    • 7. Re: need advice; regarding flagged record badgecount
                      inalaop

                      Correction made; i am new to this forum so don't know how these flags work; props given to Dave for the answer.

                       

                      Derrick