8 Replies Latest reply on Oct 12, 2014 9:17 PM by chrislines



      Forum Members


      Grateful for help on what I think is a scripting issue.


      I am working on a home-use solution to log events related to my bonsai trees and bonsai pots. On my EventsLog layout, among other fields, I have the following:



      : Bonsai

      :: Pot


      Type (conditional values based on category)









      Having chosen category and type I want to:


      IF bonsai, select the relevant bonsai tree from a dropdown, ignore pot dropdown, go to notes field;


      IF pot, select the relevant pot from a dropdown; ignore bonsai dropdown, go to notes field.


      Grateful for advice on the script I should use to enable the selection. Grateful for confirmation that I should use OnObjectExit to trigger my script. Grateful for advice if I need parameters.


      Thank you in advance.

        • 1. Re: Scripting

          chrislines wrote:

          IF bonsai, select the relevant bonsai tree from a dropdown, ignore pot dropdown, go to notes field;

          IF pot, select the relevant pot from a dropdown; ignore bonsai dropdown, go to notes field.


          I cannot see how you could automate the selection of the Bonsai you want to create the log entry for** (other than coming from the Bonsai record, of course; or having a default Bonsai stored somewhere).


          So I guess what you're really asking for is a conditional value list that displays either a bonsai or a pot, depending on the type and category selected – which is primarily a matter of data structure, not of scripting.


          If you've flagged your bonsais with the correct category and type, create a conditional value list that is based on a relationship between the eventLog table occurrence (TO) and a new TO of Bonsais


          eventLog::gType = Bonsais_forValueList::type

          eventLog::gCategory = Bonsais_forValueList::category


          assuming that you're using global fields as selectors for type and category.


          Now you would have only one field and popup/dropdown into which to enter the Bonsai name for the event (well, in fact you should use IDs …)


          **As a matter of fact, you could automate the creation of an eventLog entry if there is only one matching Bonsai record of selected type/category … if that's what you want.


          After that it boils down to “Go to notes field after selecting a Bonsai” – which could indeed be an OnObjectExit trigger.

          chrislines wrote:

          Grateful for help

          Grateful for advice

          Grateful for confirmation

          Grateful for advice if I need parameters

          You sure are grateful …

          1 of 1 people found this helpful
          • 2. Re: Scripting

            Thank you erolst. Your response helped, but I'm still stuck. I have created the conditional value list and it works. (BTW, I am using IDs rather than names.) So, when I select category:bonsai I only see the relevant types for bonsai and likewise when I select category:pot I see the relevant types for pots. Having selected the category and type, now I want to go to bonsaiID  OR  potID so the log entry reflects one or the other. I have drafted a script and attached it to the OnObjectExit trigger on the type field. But nothing's happening, so have assumed the script doesn't work.


            If [tblLog::Category = "Bonsai"]

                 Go to Field [tblLog::_kf_BonsaiID]


                 Go to Field [tblLog::_kf_PotID]

            End If

            Exit Scrip []


            In addition to getting to bonsiaID field or potID field, I then want to move to the notes field.


            Based on my assumption it's the script that's the problem, where have I gone wrong? And what do I need to do to make it work in the way I've described? And what lines do I add to it so I move to the notes field.

            • 3. Re: Scripting

              After your first post I thought I had an inkling of what this is about, but now I'm not so sure. Please describe the tables you have and their relationships, or even better, post a copy of your db.


              (You need to use the Advanced Editor to post a (zipped) copy of your file.)

              • 4. Re: Scripting

                So, is the second option, after the user chooses bonsai or potted a single field you want with a different value list attached, depending on which selection is made? Or is it two different fields?


                Either way, using the "Hide Object When..." condition will be easier than a conditional value list.


                Just create two copies of the field, one with the Bonsai value list, the other with the Potted value list. Set them to hide unless the value in the first field is correct.


                Eg: Hide when... = Not ( EventsLog::Category = "Bonsai" )



                *Re-read your second post.


                Message was edited by: DavidJondreau

                1 of 1 people found this helpful
                • 5. Re: Scripting



                  Thank you. I have today upgraded to FMP13. Let me work through help so I understand how to use 'HideObjectWhen'. If I continue having problems I will come back to you. Thank you again for your help.

                  • 6. Re: Scripting



                    I've just upgraded to FMP13. I'll spend some time getting used to it. I'll come back to you later if I need further help. Thank you again for your help to date.

                    • 7. Re: Scripting

                      The beauty of the new conditional visibility (ie. Hide Object When …") is that an object (in your case a field) that is hidden has, in effect, disappeared from the layout altogether.  It cannot be accessed at all while it is hidden, so users cannot accidentally stumble upon it, as can happen with conditional formatting (ie. the earlier trick of making a field invisible by making it the same colour as the surrounding background).


                      Thus, in the solution suggested by David, only the relevant field and its value list will be acessible.

                      • 8. Re: Scripting



                        Thank you for your post. I still working through David's suggestion, but I think I've got it working. Thank you again for your contribution.