1 2 Previous Next 24 Replies Latest reply on Nov 25, 2012 5:30 AM by RichardDavies_1

    Scripting issues



      Scripting issues


      I've been having some issues writing a script for a database I've been developing, and I hope someone can help. I'm not even sure what I want to do is possible, hence my confusion.

      Essentially what I want to happen is for FileMaker to check whether a particular value from a drop-down value list has been selected; if it has, then I want another field, one that was not previously visible on the layout, to appear. This visible / invisible field is obviously part of a table; I'm hoping that it will appear only when this “trigger” value has been selected.

      I'm using FileMaker Pro 12 and I'm pretty new to the world of scripts, so any help will be appreciated. I can provide further clarification if required.




        • 1. Re: Scripting issues

          Any number of methods can be used to control a layout's visibility and accessibility (not quite the same thing).

          Here is an .fp7 demo file of several methods. To use with FileMaker 12, launch FileMaker and use open from the file menu to open it. This will produce a new copy in the .fmp12 format.


          • 2. Re: Scripting issues

            You could use a merge field  or merge variable.  The merge field would be a calculation field.  If(testfield="TEST";"TEST") or it could display the contents of another field.

            • 3. Re: Scripting issues

                   Thanks very much for the responses.


                   I mentioned in my post that I'm pretty new to all this, so I have to say I didn't understand either suggestion (I downloaded the demo file, but I couldn't see how I could apply the solutions to my situation).

                   Is it possible that you could help further?

                   Thanks again



              • 5. Re: Scripting issues

                     "Help further" is a big vague. Can you make a specific request? How far can you get at this point before things don't work? (Don't worry about being too "basic" in your questions, this is primarily a forum for new users and we get those type of questions all the time.)

                • 6. Re: Scripting issues

                       Thanks for getting back to me.

                       Essentially, I'm still no closer to solving the issue I outlined at the start of this thread as the suggestions I've received (for which I'm obviously grateful), are too technical for me to understand. I'm sure you've better things to do than to help me further, but a step-by-step guide would be really useful at this point.

                       Thanks once again



                  • 7. Re: Scripting issues

                         I don't know exactly what tables, relationships and fields you have to work with. My example will thus be pretty general and you'll have to subsitute your names for mine.

                         Let's say you have a table named: MainTable and these four fields defined for it:

                         __pkMainTableID  Make this an auto-entered serial number field so that every record in the table will get a unique identifying number in this field. If this is a table that already has records in it, this field will be blank in those fields and only new records will get a serial number automatically. If this is the case, let me know and I'll tell you how to update your existing records so that they also have serial numbers.

                    DropDownField Make this a field formatted with your drop down list. For this example, I'll make it a text field with two values: "Apple", "Orange".

                    ExtraField Make this the data field that will appear or disappear when the value "Apple" is selected in the drop down field.

                    constApple Make this a calculation field. Select Text as the return type and put "Apple" (quotes included) as the calculation expression for this field.

                         Now click the Relationships tab and make a new occurrence of MainTable:

                         In Manage | Database | relationships, make a new table occurrence of MainTable by clicking it and then clicking the duplicate button (2 green plus signs). You can double click the new occurrence box to get a dialog to appear where you can rename the new occurrence box as MainTableSelf.

                         We have not duplicated a table. Instead, this is a new reference to the same table already present in your database.

                         Add it to your relationships to get this:

                         MainTable::__pkMainTableID = MainTableSelf::__pkMaintableID

                         Then drag from MainTable::DropDownField to MainTableSelf::constApple to make it be this relationship:

                         MainTable::__pkMainTableID = MainTableSelf::__pkMaintableID AND
                         MainTable:DropDownField = MaintableSelf::constApple

                         Now click OK to exit Manage | Database, go to your layout for MainTable and enter layout mode.

                         Use the portal tool to add a portal to your layout. Make this a one row portal and select MainTableSelf as the related table for this portal.

                         Put ExtraField from MainTableSelf in the row of this portal.

                         Now return to browse mode and test your design. When you select "Apple", you should see the ExtraField appear in the portal row. If you clear the field or select "Orange" it should disappear. Once this is working for you, you can return to layout mode and make the borders of the portal invisible so that this field looks like any other field on your layout.


                    • 8. Re: Scripting issues

                           Apologies if you are reading this in your Email. I left out a major part of my last post. I've edited it to correct this error, but that error won't appear in your email. You'll need to go to the forum and read it there.

                      • 9. Re: Scripting issues

                             Thanks very much for getting back me to so promptly.

                             I've followed your thorough instructions, and the solution works perfectly. The next step is obviously to apply it to the database I'm creating.

                             Needless to say, I'm very grateful to you for your help and patience.


                             Yours sincerely




                        • 10. Re: Scripting issues

                               Sorry, but I did have another question! How do I avoid getting this error when I attempt to make the borders of the field in the portal invisible?


                               "Line attributes can only be applied to fields that have borders specified through the Inspector."

                               Thanks again


                          • 11. Re: Scripting issues

                                 Note that the message says "Fields". Select only the portal, not the fields inside the portal. You may need to carefully click an edge of the portal to select just it or you may want to select both, then shift click to deselect the field.

                                 Or you can just ignore this warning message as long as you don't want visible borders for your field.

                            • 12. Re: Scripting issues

                                   FAO PhilModJunk

                                   You may remember that you recently helped with a problem I was having with a FileMaker 12 database I had created. Essentially, I was hoping to have a field appear once a "trigger" value had been selected from a drop-down list associated with a neighbouring field. You very kindly sent me a thorough solution to this issue.

                                   Unfortunately, despite numerous attempts, I have singularly failed to apply the solution to my database. I got it to work in another one I specially created to see your idea in action, but I cannot get it to work with the existing database. I've even tried to create a new database specifically around your solution, but even that didn't work. As you can appreciate, this is both enormously frustrating and baffling.

                                   Consequently, I have a request to make of you. Would it be possible for me to send you my database attached to a personal email (along with explanatory notes), so that you might add the solution? I realise this is an impertinent request coming as it does from a complete stranger, but I'm unable to see another work-around. I'm sure you have far better things to do with your time, but I will be genuinely grateful for your assistance. I want to assure you that this is an honest request and that any email address you make known to me will not be inundated with spam.

                                   Perhaps you'll be kind enough to give me your reaction to this request.

                                   Yours sincerely

                              • 13. Re: Scripting issues

                                     You can upload to a share site such as a drop box account: http://db.tt/foVz06QB

                                     And then post your file's download link here.

                                     Or see your inbox for a private message from me with an email address. Please note, though that I get this request fairly often and my time to download and examine such files is very limited.

                                • 14. Re: Scripting issues
                                  Dear Phil
                                  You may remember that I sent you a database toward the end of September; it was one with which I’d been having problems and we discussed it in a thread on the FileMaker forum entitled “Scripting issues”. I’d basically come to the end of my tether with it and kindly agreed to see if you could help.
                                  I just wanted to check whether you’ve received the file. I know you get very little time to look at these things, so please don't think I’m bothering you; I just want to check it arrived safely.
                                  With best wishes


                                  1 2 Previous Next