6 Replies Latest reply on Mar 10, 2016 6:47 PM by itraining

    Cant delete the global field by Clear function

    cillion

      Hi all!

      I have created a script for creating a instance in a entity, but it is very importent to remove the value in the name field after creating. This I have tried a number of way with the function Clear, but no luck yet. Most likely this is an easy fix, this is my script:

       

      2016-03-09_21-40-11.png

        • 1. Re: Cant delete the global field by Clear function
          Vaughan

          Don't use Clear. Use Set Field. Clear needs the target field to be on the current layout to work. Set Field does not.

           

          Set Field [ Prosjekt::z_newProject ; "" ]

          • 2. Re: Cant delete the global field by Clear function
            cillion

            Okey, the target field was a part of the current layout tough. hmm.

            But I change it to set field and this worked. Thanks alot vaughan!

            • 3. Re: Cant delete the global field by Clear function
              itraining

              Hi slaekke

               

              The Clear script step does require a target field to be set but the field NO longer has to be visible on the layout.

              • If the field is on the layout - Clear will work
              • if the field is on the non-visible part of the layout (whatever that area to the right is called) - Clear will work.
              • if the field is NOT on the layout - Clear will work

               

              It certainly used to be true the field had to be visible on the layout for Clear to work but at some stage FileMaker Inc resolved the limitation and the fields no longer have to be on the layout.

               

              The Replace Field Contents script is another script that has changed behaviour. For years I kept writing scripts with a dedicated replace layout because in earlier versions of FMP  the field had to be only the layout for the script step to work. From about FMP9 onwards, that limitation was removed.

               

              The 12/13/14 help documentation does not mention this change in behaviour. Maybe it was mentioned in FMP9/10 when the behaviour changed but there is no mention that the field "is no longer required to be on layout"..

               

              Not sure if other script steps like Cut, Copy, Paste and Insert Field Contents work when the field is NOT visible on the layout.

               

              Hope this helps

               

               

              Michael Richards

              Brisbane (Australia)

              • 4. Re: Cant delete the global field by Clear function
                BruceRobertson

                "

                • if the field is NOT on the layout - Clear will work"

                 

                Nope.

                Error 102

                The field MUST be on the layout.

                • 5. Re: Cant delete the global field by Clear function
                  Vaughan

                  Maybe the field was not set to allow entry our was hidden?

                  • 6. Re: Cant delete the global field by Clear function
                    itraining

                    Sorry, my bad. Thanks for the prompt correction Bruce.

                     

                    The fact that a field no longer needs to be on the layout for Replace Field Contents to work, I did build a quick test database to experiment with the Clear script step before posting my reply. Duplicating a layout, I forgot to remove the fields from the non-visible area to the right and I thought the layout had NO fields on it while testing. Doh!

                     

                    The field MUST be on the layout for the Clear script step to work.

                     

                    Michael Richards

                    Brisbane (Australia)