4 Replies Latest reply on Nov 21, 2016 11:10 AM by philmodjunk

    Getting values from a value list

    ndveitch

      Hi there,

       

      I need to ask a quick question regarding the ValueListItems (  ) and Substitute ( ) function. I have a global field that has a checkbox set based off a field in a temp table. Then I have a global calc field, ValueListItems ( Get ( FileName ) ; "FIFONames" ) which lists all the values in my value list on the checkbox field. I was playing around with an idea of comparing the global checkbox field to the global valuelist field to see which items have been selected and I noticed something strange in dataviewer. Well it looks strange, but that could be because I am using the functions incorrectly .  In dataviewer I tried a calc, Substitute ( z_FIFOOrder::zg_Index ; z_FIFOOrder::zg_Names ; "" ).

       

      The calc worked well if I only selected one item or multiple consecutive items in the checkbox field. The minute I jumped over on of the choices or i select them in a funny order the whole list is shown. for example:

       

      List:

      1 - Apple

      2 - Banana

      3 - Cherry

      4 - Dates

      5 - Eggplant

       

      If no names are selected in the checkbox field, then all the names appear in dataviewer. If I select 1 then 2 then 3, the step in dataviewer will remove apple, banana and cherry from the list. If I select 3 then 4 then 5, the step in dataviewer will show only cherry, dates and eggplant. Yet if I had to select 1 then 2 then 4, or 1 then 4 then 2, all the values appear in the subsitute ( ) in  dataviewer.

       

      Why does this happen?? Surely selecting the values in random order shouldn't matter, or does it come down to the way the data is stored when the values are selected in the checkbox?

        • 1. Re: Getting values from a value list
          erolst

          ndveitch wrote:

          Why does this happen?? Surely selecting the values in random order shouldn't matter, or does it come down to the way the data is stored when the values are selected in the checkbox?

          Your selection to substitute isn't processed item by item, but as a block of text (which is how Substitute() works).

           

          If that block does not appear literally - as a contiguous whole - in the original VL, nothing happens. You need a Custom Function to perform recursive processing of individual items.

          1 of 1 people found this helpful
          • 2. Re: Getting values from a value list
            ndveitch

            Cool thanx

            • 3. Re: Getting values from a value list
              taylorsharpe

              If you want to get more into manipulating arrays, you can look at plugins like MBS that can take an array and give you a unique list of what is in the array or sort it or any of the CURL functions you can think of.  FM's text manipulation tools are OK, but there are options if you want to get deeper into it. 

              1 of 1 people found this helpful
              • 4. Re: Getting values from a value list
                philmodjunk

                In your check box field, items are entered into a list of return separated values in the order in which the user clicks the check boxes. The ValueListItems function will list them sorted in ascending order.

                 

                It is possible to set up an auto-enter calculation that automatically updates the list of selected values in the check box field to also be sorted in ascending order--which might make comparing values a lot simpler for you.

                 

                FilterValues ( ValueListItems ( "" ; "YourValueLIstNameHere" ) ; Self )

                 

                Be sure to clear the "do not replace existing values..." check box.