4 Replies Latest reply on Sep 9, 2014 12:49 PM by philmodjunk

    If issue

      Title

      If issue

      Post

      I have part of a script that is designed to enter a figure into a tax field depending what data is entered in another field. 

      The target fields are called  INVOICE DETAILS::VAT Rate (result to be 0 or invoicedetails_PREF::Tax Rate) and INVOICE DETAILS::VAT Code and the result is either EU export, "Non-EU Export" or Standard. I want this to change by the script depending on the data in the  INVOICE DETAILS::Billing_Country field. 

      Every thing else to 

       

      I did try a series of Ifs in my script but it didn't work reliably...

       

             
      • If [ INVOICE DETAILS::Billing_Country = "" or INVOICE DETAILS::Billing_Country = "United Kingdom" or INVOICE DETAILS::Billing_Country = "Northern Ireland" or INVOICE DETAILS::Billing_Country = "Wales" or INVOICE DETAILS::Billing_Country = "Scotland" or INVOICE DETAILS::Billing_Country = "Cornwall" ]
      •      
      • Set Field [ INVOICE DETAILS::VAT Rate; invoicedetails_PREF::Tax Rate ]

       

             
      • Else If [ INVOICE DETAILS::Billing_Country = "France" or INVOICE DETAILS::Billing_Country = "Austria" or INVOICE DETAILS::Billing_Country = "Belgium" or INVOICE DETAILS::Billing_Country = "Germany" or INVOICE DETAILS::Billing_Country = "Greece" or INVOICE DETAILS::Billing_Country = "Ireland" or INVOICE DETAILS::Billing_Country = "Italy" or INVOICE DETAILS::Billing_Country = "Luxembourg" or INVOICE DETAILS::Billing_Country = "Spain" or INVOICE DETAILS::Billing_Country = "Netherlands" or INVOICE DETAILS::Billing_Country = "Bulgaria" or INVOICE DETAILS::Billing_Country = "Cyprus" or INVOICE DETAILS::Billing_Country = "Czech Republic" or INVOICE DETAILS::Billing_Country = "Denmark" or INVOICE DETAILS::Billing_Country = "Estonia" or INVOICE DETAILS::Billing_Country = "Finland" or INVOICE DETAILS::Billing_Country= "Hungary" or INVOICE DETAILS::Billing_Country = "Malta" or INVOICE DETAILS::Billing_Country = "Portugal" or INVOICE DETAILS::Billing_Country = "Sweden" or INVOICE DETAILS::Billing_Country = "Portugal" ]
      •      
      • Set Field [ INVOICE DETAILS::VAT Code; "EU Export" ]
      •      
      • Set Field [ INVOICE DETAILS::VAT Rate; 0 ]
      •      
      • Else
      •      
      • Set Field [ INVOICE DETAILS::VAT Code; "Non-EU Export" ]
      •      
      • Set Field [ INVOICE DETAILS::VAT Rate; 0 ]
      •      
      • End If

      Any suggestions?

      Thank you

       

       

        • 1. Re: If issue
          philmodjunk

          Hmmm, never would have imagined that "Cornwall" was a "billing country" on the same level as Ireland or Wales...

          What is the relationship between Invoice and Invoice Details? I have a vague recollection that it's not the invoice to invoice details relationship found in the invoices starter solution... Something along the lines that Invoice details contains most of the invoice info and a related Invoice record is created to assign an invoice serial number to it? (Never, ever assume that others will remember your design from previous posts, there's just too much chance that they won't remember correctly if at all.)

          And are you on a layout for Invoice or Invoice Details at the time you run this script?

          • 2. Re: If issue

            I agree - but you never know who might input that in as a country!  My Customers table is linked to the invoice details table. The script is launched from the Customers table but half way through a 'create order' script. At the point of execution, the layout is on the invoice details layout. I think I may have answered my own question! Is this the issue? It should relate to the TO of customers and not the from the invoice details layout?

            But yes you were correct in your summary of my invoice table for serial number and Invoice details table for 'details'!

            • 3. Re: If issue

              Just realised I had forgotten that my address fields are already in my invoice details table so the problem wasn't what I thought.....

              I can paste in the entire new quote/order script if that may help?

              • 4. Re: If issue
                philmodjunk

                but you never know who might input that in as a country!

                But if this is date entered into FileMaker, entering spurious/incorrect data such as this can be prevented in a number of ways. If this is data imported from another source, it would seem that many other possible values might also appear...

                You'll need to do something more if you want some help as you've indicated that the problem "wasn't what you thought" but that leaves anyone reading this into the dark. Posting the script might help, but please look at it from the eyes of others and make sure to document the key details such as the context from which the script is executed. (context: What layout, found set, current record, sort order is "current" at the time this script begins execution. Not all of those details may be relevant but all might affect how a script executes.)