2 Replies Latest reply on Nov 30, 2012 6:41 AM by LyndsayHowarth

    Adding text in a field conditionally

      Hi all

       

      This is my first post and i hope i will get some answer to my question.

       

      Background:

      I have a design that i use for maintenance task lists.

      One task list can occur several times over the year. The have numbers like the pic below.

       

      Task list

      Task list counter

      Maintenance number

       

      The combination of these fields can occur several times over a period.

       

      Now, if i write a comment in the Comments field, i would like that to show in the result field. That means that every time i write something new in the Comments field i would like to add that text to the previous text in the Result field if the Task list, Task list number and Maintanance Number are the same. The field Comments should be able to be emptyed and still the text should appear in Result.

       

      Also if i insert a picture in the Image container in one record, the Image container should hold the same picture in all records with the same combinations of said fields.

      FM.jpg

      I hope i have made my self clear...

       

      Best regards

      Mats "FileMaker Rookie", Sweden

        • 1. Re: Adding text in a field conditionally
          LyndsayHowarth

          Hi Mat,

           

          There are a number of ways you could tackle this. It really depends on whether you want 1. the Results to be a single field with a running (and dated?) record of each comment... or 2. each comment to generate a new record in a Results table.

           

          #1, create an OnSave() or OnExit() script trigger script that would Insert the comment text and the date into the field either at the top or bottom of the text already there.

           

          #2 create a new table called Results with fields: Comments, Date (auto enter), Tasklist number, Maintenance Number and maybe Task List Counter (depending) and anothertext field we'll call 'empty'.

          Next create a field we'll call 'one' in this task table that is a calculation which has a result of '1'.

          Then create a relationship between Tasklist and Results tables where Tasklist number, Maintenance Number and if applicable Task List Counter all equal their counterpart but where one does not equal empty. Allow this relationship to create new records and call it 'Task_Results_New'.

          Then create another relationship between Tasklist and Results tables where Tasklist number, Maintenance Number and if applicable Task List Counter all equal their counterpart but where one does equal empty. Don't allow this relationship to create new records and call it 'Task_Results'.

          where you have your current Results field... replace it with a portal showing the 'Task_Results'... turn on your scrollbars.

          Then change the Comments field on the layout to Task_Results_New::Comments. It will always be empty once you leave the field.

           

          #2 must have a unique value (which may be the combined Tasklist number, Maintenance Number and maybe Task List Counter fields info) to relate to Results and ensure that there are not 2 identical task records. The best way around this and as a better way to manage this in general would be to add an auto-enter serial ID key field in Tasks and a matching field In the Results table and then add the match in the relationships. The missing data will be added by the Task_Results_New Relationship for Tasklist number, Maintenance Number and if applicable Task List Counter and the serial ID and the value 1 will be entered into the empty field which means that it becomes the same value as the one field hence will no longer show the comment but will show an extra line in the Task_Results portal.

           

          I hope that makes sense and helps...

           

          - Lyndsay

          • 2. Re: Adding text in a field conditionally
            LyndsayHowarth

            Hi Mats,

             

            Thank you for your private reply... but I would really rather keep things public. Someone else might learn from the exercise.

            You have asked me for more detail about how I would do #1.

             

            I have attached a little demo...

            1 of 1 people found this helpful