1 Reply Latest reply on Feb 4, 2011 4:17 PM by philmodjunk

    Auto-populating fields with loop script



      Auto-populating fields with loop script


      I am having some problems trying to auto-populate fields using a script. 

      I have a two tables Cases and Calculation. I am using a local variable to as a counter. Then I use the counter to compare it's current value versus values in a field in Cases. Values are numerical. 

      Set Variable [$count; Value:0]


      If[$$count = Cases::_LocationID]

      Set Field [Calculation::_LocationID = Cases::_LocationID]

      End If

      Goto Record [Next; Exit after last]

      Exit Loop If [$count = $count + 1]

      End Loop

      Unfortunately, loops once and quits. It populates only 1 field

        • 1. Re: Auto-populating fields with loop script

          There's a number of problems here.

          $count and $$count are two different variables.

          Set field [Calculation::_LocationID = Cases::_LocationID]

          is missing the first parameter. Set field should have the format: Set Field [table::FieldtoReceivevalue ; Expressiontocalculatevalue]

          This step doesn't really make sense either:  Exit Loop If [$count = $count + 1]

          It will always evaluate as true and thus exit in all cases (which is why your loop exits the first time around in all cases.anytime you have something like $count = $count, you are comparing the value to the left of the = with the value to the right. This will always be true (numeric value 1) and then you add one to it to produce the value, 2. In an If or exit loop If step, any expression that evaluates to a value other than 0 will evaluate as true.

          Perhaps you should describe in more detail, what this script is supposed to do.