AnsweredAssumed Answered

Any issues with putting text in a container field for copying?

Question asked by ericjlindholm on Oct 10, 2018
Latest reply on Oct 11, 2018 by philmodjunk

I love utility scripts.  I was re-tooling a few of my copy to clipboard scripts down to a single script that works anywhere.  During the process, I realized that I can set a container field with a text value and then copy it out.  Ive done a fair bit of testing and trolling the web for previous post.

 

I am just asking you much more experienced developers if this is going to bite me in anyway?

 

Utilities: Copy to clipboard( value(s) )

 

#can take a text or a field reference including container data.
requires that the field UserGlobals::CaptureContainer be on the layout

 

  1. Set Variable [ $input; Value:Get ( ScriptParameter ) ]
  2. If [ IsEmpty ( $input ) ]
  3.   Show Custom Dialog [ Message: "no value to copy"; Default Button: “OK”, Commit: “Yes” ]
  4.   Exit Script [ Result: False ]
  5. End If
  6. #make sure the field is on the layout
  7. If [ IsEmpty ( FilterValues ( GetFieldName ( UserGlobals::CaptureContainer ) ; FieldNames ( "" ; Get( LayoutName ) ) ) ) ]
  8.   Show Custom Dialog [ Message: "developer error. capture field missing on layout"; Default Button: “OK”, Commit: “No” ]
  9.   Exit Script [ Result: False ]
  10. End If

  11. Set Field
    [ UserGlobals::CaptureContainer; $input ]
  12. Set Variable [ $Message; Value:UserGlobals::CaptureContainer ] Copy [ UserGlobals::CaptureContainer ]
    Set Variable [ $error; Value:Get ( LastError ) ]
    If [ $error ]
  13.   Show Custom Dialog [ Message: $error; Default Button: “OK”, Commit: “No” ]
  14. End If
  15. Set Field [ UserGlobals::CaptureContainer; "" ] Commit Records/Requests
  16. [ No dialog ]
    Show Custom Dialog [ Title: "Copied To Clipboard"; Message: $Message; Default Button: “OK”, Commit: “No” ]
  17. Exit Script [ Result: False ]

Outcomes