2 Replies Latest reply on Jul 29, 2013 3:16 PM by flybynight

    Script Trigger to remove formatting…

    flybynight

      I know that I can define a field with an auto-enter calc to TextFormatRemove ( Self ), however… what to do when you already have a different auto-enter calc and want to preserve the "Do not replace existing value (if any)" behavior.

      I'm trying to do it with a script trigger, but it's not working for me. I want to make just a simple script that I can apply to any field on a layout where users are likely to copy & paste in text and get rid of the formatting.

       

      This is the 1-line script I have:

      Set Field By Name [Get ( ActiveFieldName ); TextFormatRemove ( Get ( ActiveFieldName ) )]

       

      I've been trying to just select the field and run this script from the Manage Scripts window, and it doesn't do what I'm expecting (get rid of bold, italic, other fonts, etc).

       

      Once I have the script working, I plan to apply it as an On Object Exit trigger.

       

      Always appreciate the help.

      Thanks!

      -Shawn

        • 1. Re: Script Trigger to remove formatting…
          DavidJondreau

          >Set Field By Name [Get ( ActiveFieldName ); TextFormatRemove ( Get ( ActiveFieldName ) )]

           

          1) Get ( ActiveFieldName ) returns just the field name, not the table name. Set Field by Name needs the whole thing. You can use Get ( ActiveFieldTableName ) & "::" & Get ( ActiveFieldName ) instead. I prefer a simple custom function that does the same thing.

           

          2) The second Get ( ActiveFieldName ) should be Get ( ActiveFieldContents ).

           

          DJ

          • 2. Re: Script Trigger to remove formatting…
            flybynight

            Thanks! I knew it had to be a simple fix. Once I had the table name with it, then it worked enough to replace the contents, with the name of the field, as you pointed out. But at least, then I knew part of it was working and it was clear what to fix.

             

            I guess I try to avoid CFs, for something that is so easily done with built-in functions. Just seems to complicate things and make them less portable. Just my $.02.

             

            Laters,

            -Shawn