1 Reply Latest reply on Feb 23, 2012 1:12 PM by RayCologon

    Obtaining a value and calculation a result

    andy@the-wod.co.uk

      I have:

       

      Client records

      Purchase orders (in addition to the total number of session purchased I am displaying a list of "session records" related to each purchase order)

      Session records (I provide services by the hour purchased in bulk by client)

       

      I have got this far:

       

      I create a client record

      I can then create a purchase order

      I can then create a session record that will pull in a list of clients who have a purchase order, select from that list a client and then select a purchase order associated with that client. I can display the total number of sessions purchased from the purchase order in a field on the session record

       

      Currently I am then manually entering the current session number into the session record

       

      What I would like to happen is:

       

      on selecting a purchase order number and exiting the select purchase order number field run a calculation/if statement that will carry out the following action

       

      1. evaluate the total sessions purchased from the purchase order record

      2. obtain the last current session number on the current purchase order record (on the purchase order record there is a list of all session records related to that purchase order, the list displays the current session number for each record)

      3. check that current session number is less than the total sessions purchased

      4. if true than add "1" to the value in current session number and place that value into the field current session number in the current session record and move to the next field

      5. if false then maybe provide a means of displaying a dialogue saying "select a different order or purchase more sessions"

      6. if ["select a different purchase order"] then go to the field select customer order number where an alternative purchase order can be selected

      7. if ["purchase more sessions"] then got to layout [purchase orders] to create a new purchase order

       

       

      What I would like help on is:

      Is below the basis of the if statement?

      Can I display a dialogue?

      How do I get the value form the last line in the list field?

       

      Here is my feeble attempt at the if statement so far :-(

       

      if (total sessions purchased) > (current sessions number) then take the "current sessions number" from the last session on the current purchase order and add "1" to value, take this value and place it into the field (current session number) of the current session record

      end if

      or

      if (total sessions purchased) = (current sessions number) by taking the "current sessions number" from the last list line on the current purchase order then [display a dialogue that says "select a different order or purchase more sessions"

      if ["select a different order"] then go to the field [select customer order number]

      end if

      else

      if ["purchase more sessions"] then got to layout [purchase orders]

      end if

      end if

       

      Thank you for any help possible.

       

      Andy

        • 1. Re: Obtaining a value and calculation a result
          RayCologon

          andy@the-wod.co.uk wrote:

          What I would like to happen is:

          on selecting a purchase order number and exiting the select purchase order number field run a calculation/if statement that will carry out the following action...

           

          Hi Andy,

           

          Rather than a calculation (as such), I believe you might wish to explore coding your logic as a script, and then setting an OnObjectExit script trigger on the purchase order number field to call the script when the user leaves the field.

           

          A script can step through a series of conditions, along the lines you've described, taking actions such as displaying a dialog, placing the cursor in a field, going to a layout etc. So in that sense, yes, you are on the right track. Having said that, to answer your other specific question:

           

          andy@the-wod.co.uk wrote:

          How do I get the value form the last line in the list field?

           

          - you can construct a calculation to retrieve the last value in a text list in several ways. Here's one:

           

          RightValues(YourListofValues; 1)

           

          This method will return the last value with a trailing carriage return. If that's a problem then you could either strip the carriage return off, or use a different approach such as:

           

          GetValue(YourListofValues; ValueCount(YourListofValues))

           

          Notwithstanding the above, once you've started the process of converting your logic into a script, you may have other specific questions about issues that arise, and I'm sure folk here will be happy to assist.

           

          Regards,

          Ray

          ------------------------------------------------

          R J Cologon, Ph.D.

          FileMaker Certified Developer

          Author, FileMaker Pro 10 Bible

          NightWing Enterprises, Melbourne, Australia

          http://www.nightwingenterprises.com

          ------------------------------------------------