6 Replies Latest reply on Mar 6, 2012 10:01 AM by philmodjunk

    Conditional Formatting



      Conditional Formatting


      I want to write a script so that when a date or anything is entered into one field the contents in a different field are changed automatically.

      I tried to set a "Script Trigger" with an OnObjectEnter script but maybe the script I wrote to be automated was wrong.

      For the script i tried to use "Replace Field Contents" Scipt but I'm not sure how to write it out so that when a date is entered in Field A the text in Field B should = "Shipped"

      Am I even using the right script trigger? How would you do this?

      Thank you!



        • 1. Re: Conditional Formatting

          please don't use replace field contents for this, that can modify a value in a field for every record in your found set. That could be hundreds of records modified in a single step!

          You may not need a script at all. An auto-entered calculation might be set up that updates the second field in response to data entered into the first.

          • 2. Re: Conditional Formatting

            Thank you for that advise. You were right... the replace field contents does change them all.

            I'm not sure how I would use the auto-entered calculation.  To my understanding the auto-enter option would fill in the field as soon as the record is created.

            Am I wrong?  I'm pretty new to filemaker and scripting so I have a very limited knowledge of the different script uses.

            • 3. Re: Conditional Formatting
              This is the auto-enter calculation for the text field: Field B

              not IsEmpty ( Field A ) ; "Shipped" ;
              • 4. Re: Conditional Formatting

                There's an auto-enter option: "do not replace existing value..." It depends on what you need as to whether you want this option selected or not for this field. If it is selected, then the contents of Field B will change any time the the contenst of Field A change. If it is cleared, it will enter a value when Field A is changed only if there isn't already data in Field B.

                A straight up calculation field can also be used--it just depends on what you need to set up here that works best for you:

                Case ( Not IsEmpty ( Field A ) ; "Shipped" )

                Would produce much the same result as an auto-entered calculation with the "do not replace..." option cleared.

                Note that there are differences between an auto-entered calculation and a calculaiton field depending on whether fields referenced in the calculation are defined in the same table or a related table.

                Both Raybaudi and I are assuming that both fields are defined in the same table.

                • 5. Re: Conditional Formatting

                  Yes, they are in the same table.  Would this calculation go in the "B" Field?  it keeps putting "0" in my B field.

                  • 6. Re: Conditional Formatting

                    Yes, this would be the calculation for your B field. Is the B field of type text or type number? It should be of type text here if you want to display a text result.