4 Replies Latest reply on Sep 7, 2014 3:14 PM by BruceRobertson

    Populate repeating field from List()

    renti

      Hello,

       

      could please anyone advice me why this Let function is not working as expected ?

       

      Let (

      [ $First = GetValue (List (T02_Partes_DETALLES_TRABAJADORES::Id_detalles_trabajador);1); //

      $Second = GetValue (List (T02_Partes_DETALLES_TRABAJADORES::Id_detalles_trabajador);2);

      $Third = GetValue (List (T02_Partes_DETALLES_TRABAJADORES::Id_detalles_trabajador);3);

      $myList = List ($First ; $Second ; $Third) ];

      GetValue ($myList ; Get ( CalculationRepetitionNumber ) )

      )

       

      When i use the Data Viewer, $First, $Second and $Third are correct, but $myList = $First !!!

      If i change 2 any variables ($First,$Second or $Third) for a constant or Text it works fine.

       

      i hope someone could help me out with this.

       

      thanks.

       

      FM13pro.

        • 1. Re: Populate repeating field from List()
          erolst

          I've no idea why your calc doesn't work correctly – it does for me; and I couldn't observe that …

          renti wrote:

          $myList = $First !!!

           

          … but then in its current form the calculation is hard to debug …

          [ $First = GetValue (List (T02_Partes_DETALLES_TRABAJADORES::Id_detalles_trabajador);1); //

          $Second =  GetValue (List (T02_Partes_DETALLES_TRABAJADORES::Id_detalles_trabajador);2);

           

          You can make it much easier on the eyes (and any troubleshooting efforts) if you use Let() consequently:

           

          Let ( [

            myList = List (T02_Partes_DETALLES_TRABAJADORES::Id_detalles_trabajador) ;

            $First = GetValue (myList;1) ;

            // etc.

           

          Or you could do this:

           

          Let ( [

            myList = List ( T02_Partes_DETALLES_TRABAJADORES::Id_detalles_trabajador ) ;

            myList = LeftValues ( myList ; 3 )

            ] ;

            GetValue ( myList  ; Get ( CalculationRepetitionNumber ) )

          )

           

          or simply this:

           

          Let (

            i = Get ( CalculationRepetitionNumber ) ;

            Case (

              i < 4 ;

              GetNthRecord ( Extend ( T02_Partes_DETALLES_TRABAJADORES::Id_detalles_trabajador ) ; i )

            )

          )

           

          btw, why are you using $vars as Let() variables?

          1 of 1 people found this helpful
          • 2. Re: Populate repeating field from List()
            renti

            Hi Erolst,

             

            thanks for your reply, the code is much clear the way you wrote it.

             

            I used $vars to be able to track them from the data viewer for debugging.

             

            The point of the Let calculation is to populate a repeating field, each value of the calculation to a "cell" of the repeating field.

             

            I´m trying to do it working from this post: http://fmforums.com/forum/uploads/monthly_07_2012/post-80889-0-54620500-1341593871.png

             

            The problem is i´m not able to format the myList in the rigth way to work in the last sentence: GetValue ($myList  ; Get ( CalculationRepetitionNumber ) )

             

            i can attach some screenshots on demand.

             

            regards,

            • 3. Re: Populate repeating field from List()
              renti

              Hi,

               

              Sorry,

               

              i´vent tried your last solution, but it works fine !!

              the 2 first only populate the first repeating field, like my code.

               

              thanks !!

              • 4. Re: Populate repeating field from List()
                BruceRobertson

                What's the big picture here?

                Why are you using repeating fields?

                 

                Why are you trying to populate them with a script variable - since a script variable disappears after you have run the script?