AnsweredAssumed Answered

Creating a "universal" script with variables

Question asked by DavidRoy_1 on May 15, 2013
Latest reply on May 16, 2013 by philmodjunk

Title

Creating a "universal" script with variables

Post

     I'm trying to create scripts that will modify the contents of fields by calculation.  I'd like the user to click on a field, and that click sets the value of the field to the first in a value list, next click to the next value in the list, and so forth until it cycles back to the first value in a loop.

     I can get this to work by setting the field to be a button that fires a script, then using IF statements and the "Insert Text" script step; but I would have to create a seperate script for each field that way.  (I would like multiple fields to have this behavior, and multiple fields use the same value lists)  Also, obviously that step is just inserting text, so if I update the value list I'll have to update the scripts...

     My next step was to set a $variable for the ::fieldname, but it's not working as expected and I've tried multiple ways to have the script then navigate to the field which fired the script, but no joy.

      

     Here's the latest iteration of the script (which isn't working for reasons that'll be obvious to some I'm sure)

     -----------------------------

     Set Variable [$field; Table:"Tablename::" & Get(ActiveFieldName)]

     If [$field = ""]

          Set Field By Name [$field; "result1"]

          Commit Records/Requests [No dialog]

          Exit Script []

     Else If [$field = "result1"]

      

          Set Field By Name [$field; "result2"]

          Commit Records/Requests [No dialog]

          Exit Script []

          Else

               Set Field By Name [$field; "result1"]

               Commit Records/Requests [No dialog]

          End If

          -------------------------

          Once I solve the $field variable problem, I'll then need to solve the insert-text-by-value list problem.....

          Any help would be appreaciated.

      

Outcomes