5 Replies Latest reply on Jan 23, 2012 5:57 PM by comment

    Getting values from fields to use in script

    strngr12

      Hello,

       

      This is a little compliacted to explain so I hope it's clear. I have a script that allows you to set a value for "playlist 1" and "playlist 2." Every record in the database can have either, both or none of them. What I need is a calculation that will search the entire database for all the values and output each value only once.

       

      So, for example, if there are five records such that

       

      record 1 = playlist 1

      record 2 = playlist 1, playlist 2

      record 3 = newplaylist 1, playlist 2

      record 4 =

      record 5 = playlist 1

       

      I need the output of the calculation to be: playlist 1, playlist 2, newplaylist 1.

       

      Any help, please?

       

      Thanks,

       

      Dan

        • 1. Re: Getting values from fields to use in script
          techt

          I would think that a calculation field that looks for the playlist name would be all you would need, depending on how you want to display it.

           

          Maybe something like

           

          If ( Playlist = "playlist1" ; Count ( Playlist1 ) ; )

           

          and then add a counter for each type of playlist name. You could get much fancier (case statement, patterncount, etc.), but this should give you the quick answer.

           

          Is this a report or just a counter on a layout?

           

          Tim

          • 2. Re: Getting values from fields to use in script
            comment

            strngr12 wrote:

             

            if there are five records such that

             

            record 1 = playlist 1

            record 2 = playlist 1, playlist 2

            record 3 = newplaylist 1, playlist 2

            record 4 =

            record 5 = playlist 1

             

            I need the output of the calculation to be: playlist 1, playlist 2, newplaylist 1.

             

            This would be easier if the values were return-separated instead of comma-separated. As it is, you need to start by defining a calculation field to make such conversion =

             

            Substitute ( YourField ; "," ; ¶ )
            

             

            Next, define a value list showing values from the calculation field. Finally,

             

            ValueListItems ( Get (FileName ) ; "YourValueListName" )
            

             

            will give you the result you want - again, return-separated (and in alphabetical order).

            • 3. Re: Getting values from fields to use in script
              strngr12

              Thanks for the reply.

               

              I need to use it in a script.  I'm exporting an xml for use by another program.  At the top of the xml I need to define an action for each playlist.  Then in the xml each item may or may not be put into a playlist.

               

              With each item you can create a playlist if it doesn't already exist and for each playlist created there can only be one action.  That means that befor I go through the entire xml item by item I need to first find out what playlists will be created and what the expected action for that playlist will be.

               

              With the code you wrote, wouldn't I have to know the names of the playlists first?  The problem I have is that I do not know what they will be.  I need to scan the database and find out what playlists will be created but I only want each value once.

               

              For example, I import from an outside database and that database has several fields including "scene" and "shoot day."  I have a calculation performed that says:

               

              playlist_1 = "Dailies " & "scene " & scene & "Day " & shoot day

               

              If there are 2 different scenes in the outside database it will create two different values.  I need to know what those values are so that I can define an action for each one.

              • 4. Re: Getting values from fields to use in script
                strngr12

                Hello Michael,

                 

                The problem I have is that every day a new set of fields will be imported into the script from an outside database so I have no idea from day to day what the names of the playlists will be.  Also, teh script allows a user to type in by hand what they want the playlist to be called so they may overwrite the value of any calculation I do.

                 

                Also, sorry if I wasn't clear, but each playlist will be in it's own field.  Each record has a field = playlist_1 and a field playlist_2 which may or may not have a values.  I need to scan those fields in every record in the document and return a lits of all playlists created.

                 

                I hope that's more clear.

                 

                Thanks for your help.

                 

                -Dan

                • 5. Re: Getting values from fields to use in script
                  comment

                  strngr12 wrote:

                   

                  each playlist will be in it's own field.  Each record has a field = playlist_1 and a field playlist_2 which may or may not have a values.

                   

                  I don't know what the purpose is here, but that doesn't sound like a good arrangement to have. Still, you could make the calculation field =

                   

                  List ( playlist_1 ; playlist_2 )
                  

                   

                  and base the value list on it as described above. This is assuming each one of the two fields contains one value only.

                  1 of 1 people found this helpful