2 Replies Latest reply on Dec 18, 2014 8:47 AM by kuta

    Copy and record data to a field from a variable field

    kuta

      Title

      Copy and record data to a field from a variable field

      Post

      Hi All,

      I'd be grateful for some help with what is probably a simple problem, but one that is giving me grief.

      I'm trying to create a script to trigger when exiting a field such that another field records the data and won't change, even if the data in the first field is deleted.

      I've tried this script which triggers OnObjectExit, but it won't put any data in the second field:

      If [Unit::CMA Resit Compensation = “ * “]
                      Copy [Select; Unit::CMA Resit Compensation]
                      Paste [Select; Unit::CMA Resit Compensation Copy]
      End If

      So when data is added to CMA Resit Compensation it will copy to CMA Resit Compensation Copy, but if the first field is set to zero in the future, the second field will still record the original data.

      Any thoughts on how I get this to work, or perhaps a smarter way gratefully received.

      Thanks in advance.

        • 1. Re: Copy and record data to a field from a variable field
          philmodjunk

          Copy and paste script steps, like the script steps that begin with the keyword "Insert" do nothing but return an error code if the field that reference is not present on the current layout. In addition to that, The Copy step destroys any data the user may have previously copied to the clipboard. This irritates and confuses users and is completely unnecessary as there are other ways to move data around that do not require the use of  copy/paste to do so.

          Also wlidcards like * are treated as simple text, not a wild card in such an If script step. (Wildcards only work in Find mode when performing a find. So your above script will only copy data if the exact quoted text, (One space followed by an asterisk followed by another space), is the total value of the field at the time the script trigger is tripped.

          But you can open field options for CMA Resit Compensation Copy and define an auto-enter calculation with this expression:

          CMA Resit Compensation

          Just leave the "do not replace existing value" check box selected and you should get what you need without any scripting.

           

          • 2. Re: Copy and record data to a field from a variable field
            kuta

            Thanks PhilModJunk; so simple and so quick.