2 Replies Latest reply on Feb 23, 2016 11:50 PM by Stigge

    Need assist - Improving my script

    Stigge

      Hi

       

      Am doing pre-invoicing within my company using Filemaker 14.

      The last thing i do in the script is to export the pre-invoicing details to an excel files, so i can send it out to all finans departments as details.

       

      Our company is devided in different "Teranga" (units). At the moment i have 18 Terangas = 18 files i need to export to.

      The script works as it is.. but.. if i need to remove or add Terangas i need to change in so many places.

      All the Terangas are stored in a Value List named "Teranga" (inkluding an empty space for drop-down list).

       

      Here is the code that am repeating 18 times in the same script:

       

      Set Variable [$Teranga; Value: "3875"]

      Enter Find Mode []

      Set Field [Collection::Teranga; $Teranga]

      Perform Find[]

      Sort Records [Restore; No dialog]

      Set Variable [$File; Value: $Teranga $ ".xlsx"]

      Set Variable [$Link; Value: "filewin:/N:/<path to placement>" & $File]

      Export Records [No dialog; "$Link"; Unicode (UTF-16)]

       

       

      Am sure i can somehow use the Value List instead of needing to set the variable $Teranga manually, i just cant figure out how :/

        • 1. Re: Need assist - Improving my script
          Mike_Mitchell

          Set Variable [ $TerangaList ; Value: ValueListItems ( "" ; yourValueListName ) ]

          Loop

              Set Variable [ $Teranga ; Value: GetValue ( $TerangaList ; 1 )

               Enter Find Mode []

               Set Field [Collection::Teranga; $Teranga]

               Perform Find[]

               Sort Records [Restore; No dialog]

               Set Variable [$File; Value: $Teranga $ ".xlsx"]

               Set Variable [$Link; Value: "filewin:/N:/<path to placement>" & $File]

               Export Records [No dialog; "$Link"; Unicode (UTF-16)]

               Set Variable [ $TerangaList ; Value: RightValues ( $TerangaList ; ValueCount ( $TerangaList ) - 1 ) ]

               Exit Loop If [ ValueCount ( $TerangaList ) < 1 ]

          End Loop

          • 2. Re: Need assist - Improving my script
            Stigge

            Thank you.. worked like a charm.. =D