5 Replies Latest reply on Sep 26, 2016 11:58 AM by philmodjunk

    Search in variables fields name

    lolli_group

      Hi,

      my last FM DB is immense, so I'd love to have scripts auto-adaptable, but I cannot.

      A simple example, to understand my need:

      Imagine I want to keep only text (not formatted) in a field, especially when users copy-paste from different external software.

      I can set a variable with Get (name field) and can transform that variable in "text only - not formatted"

      But how to compile the same field with the new variable ?

      I can only choose one of the existing fields, but I cannot use a variable to tell Filemaker which field I want to fill, isn't it ?

        • 1. Re: Search in variables fields name
          philipHPG

          Look at the Set Field By Name script step, as well as Get ( ActiveFieldName )

          • 2. Re: Search in variables fields name
            philmodjunk

            Find the field in Manage | Database | Fields and double click it.

            Select the Auto-enter Tab

            Click the option for a Calculation

            Enter this text:

            TextFormatRemove ( Self )

            Clear the "Do not replace existing value..." check box

             

            Note that you can copy and paste this expression to field after field without updating.

             

            But to answer your specific question, You can use Set Field By Name in a script to set a field named in a variable to a value.

             

            Set Field By Name [$FieldName ; //Put an expression here ]

             

            The value of $FieldName has to be a "fully qualified field reference" in the TableOccurrencename::FieldName format such as Invoices::Description.

            • 3. Re: Search in variables fields name
              FabriceNordmann

              I think what you want to achieve should be at the database level, not in scripts.

              If you want to do it by script (and add a trigger to each and every object, which I really wouldn't recommend), you can just use Set Field without specifying the field, and specify the calculation like : Trim ( TextFormatRemove ( Get ( ActiveFieldContents )) (for example, but you could also avoid leading/trailing carriage return)

               

              If you want to do it at the database level, specify an auto enter calculation like

              Trim ( TextFormatRemove ( self ))

              and un check the Do not reevaluate checkbox.

              (You can also create a custom function like text.clean ( text ) and use text.clean ( self ) in the auto enter, this will make it easier if you once want to change this calculation)

              • 4. Re: Search in variables fields name
                lolli_group

                Thank you for reply, I never used Set field by name, and this is what I needed.

                Do you prefer a Calculation field as you wrote (TextFormatRemove ( Self )) instead of a trigger in each field ?

                Why ?

                • 5. Re: Search in variables fields name
                  philmodjunk

                  Not a calculation field, but an auto-enter calculation on the text field.

                   

                  This is preferred because, once set up on a field, all pasted formatting is removed automatically no matter what layout is used when pasting into the field.

                   

                  With a scripted method, you have to do this over and over on every layout where this field is found and editable.

                   

                  On the other hand, with a scripted approach, you can allow formatting of the text on some layouts and not others--I suppose there may be cases where that might be useful.