2 Replies Latest reply on Apr 22, 2016 7:33 AM by thetasphere.fba

    SetField or Script?  Why is your way better?

    ninja

      I'm trying to click a button, consider the surrounding data, and set a field to a value based on that consideration.

       

      Two ways to go:

      Put the logic in the script

      If (Status = Open)

        SetField (Action ; "pursue")

      EndIf

      If (Status = "Closed" and Date < Get(CurrentDate))

          SetField( Action ; "Closed Early")

      EndIf.......etc, etc.

       

      Put the logic in the SetField step

      Case (

      Status = open ; "Pursue" ;

      Status = closed and Date < Get(CurrentDate) ; "closed early" ; ....etc.

       

      Both work fine, both are simple...which way do you typically use...and why?

      - Speed?

      - Multi-programmer environment for clarity?

      - Sheer preference?

      - keeping open the option for Get(ScriptParamater) ?

      - Other?

        • 1. Re: SetField or Script?  Why is your way better?
          Mike_Mitchell

          I tend to prefer the former because it makes it easier to read the script without opening up the script step. I don't believe there's a significant performance different (not that I've ever seen, anyway).

          • 2. Re: SetField or Script?  Why is your way better?
            thetasphere.fba

            I prefer a bit of a third option.  To make a script, but use the SetField with the Case() you have illustrated in your second example.

             

            Firstly, by making it a script vs a script-step via the button, I can organize the processes in one place vs several buttons across multiple layouts; so consolidation is important to me.  Secondly, I prefer the Case() in general when doing considerations of data like this since it stops after the first true evaluation.  So, though small, the processing is faster.

             

            Finally, by having in a script allows me to add in the future at-will (adding access rights, other sub-scripts, etc.), should the need arise.