5 Replies Latest reply on Mar 28, 2014 11:42 AM by Nehme

    Make unstored calculation store a value

    Nehme

      Title

      Make unstored calculation store a value

      Post

           Hello,

           I need your help to make an unstored calculation store a certain value. I am using the Filemaker Pro Advanced 13.

           I have a field (named "Assessment") that I want to hide if the "Lock" field = 1.

           Lock field is an unstored calculation:
           Case (
           Current Date   ≥  Auto Lock date
           ;1)

           Current Date: Unstored calculation: get (CurrentDate). This will allow it to always update.
           Auto Lock date: Stored calculation that generates a fixed date in the future.

           I am trying to make the Lock field keep the value of 1 once it gets to the value of 1.

           The problem is that if the user changes the date of his computer back to a value that is < Auto Lock date, the Current Date will also update and the Lock field will be empty again and the Assessment field will show again.

           I tried different calculations but none of them worked to store the value of 1, such as:

           Case (
           Current Date   ≥  Auto Lock date
           ;1;
           Lock = 1; 1)

           Can we generated a calculation that keeps the Lock value 1 (once Lock = 1, it will remain 1 even if Current Date < Auto Lock date).

           Thank you for your help.

        • 1. Re: Make unstored calculation store a value
          raybaudi

               You could change the Current Date field from unstrored calculation to a simply date field and put into it the current date on open the DB.

          • 2. Re: Make unstored calculation store a value
            Nehme

                 Thank you for your reply.

                 This seams a nice idea.
                 But the user could still change the date of the computer before entering the database. An we will end up with the same problem.

                 The issue is that I am making this Lock option for medico-legal purpose (so that the assessment could no longer be changed no matter what).

                 Thank you again.

            • 3. Re: Make unstored calculation store a value
              raybaudi

                   My answer was related to the subject of your post.
                   But the same script could control the state of the Lock field ( if it was 1, it will remain 1 )

              • 4. Re: Make unstored calculation store a value
                philmodjunk

                     I would use the OnRecordLoad trigger to perform a script that checks the date and locks the record if it is unlocked and that leaves it locked if already locked.

                     Set Field [ YourTable::Lock ; If ( Not Lock ; Get ( currentDate ) > AutoLockDate ) ]

                • 5. Re: Make unstored calculation store a value
                  Nehme

                       In fact, I have tried a lot but the calculation result came back to empty once I change back the computer's date to a previous date.
                       This is because the calculation field is unstored.
                       The problem is that, when we must recheck the date (on Database open or on Record load), it will check the new computer's date.

                       So, what I have done is that I have used the idea of Raybaudi (thanks to you).
                       This way, I will have a stable date when the database is opened.
                       Then I have made a script that will run on database exit that will definitively lock the fields, using a simple text field.

                       Thank you all for your help.