6 Replies Latest reply on Oct 28, 2011 11:34 AM by philmodjunk

    New to Filemaker need simple Script

    MacMak

      Title

      New to Filemaker need simple Script

      Post

      Hello.

         I recently purchased Filemaker and have gotten a great start and like it very much. I do however have problems writing scripts.

      I need a simple script for a FaceBook button that says if entry is "n/a" then show a pop up message saying "Link not available" otherwise go to link that is in the Facebook field.

      Hope to get some help soon as this has been bothering me for a while.

      Thanks!

        • 1. Re: New to Filemaker need simple Script
          philmodjunk

          Are you storing a URL for that "face book entry" in a field?

          If so, the script might look like this:

          If [IsEmpty ( YourTable::FaceBookURL ) or ( YourTable::FaceBookURL = "n/a" ) ]
             Show Custom Dialog ["Link not available"]
          Else
             Open URL [YourTable::FaceBookURL ]
          End IF

          • 2. Re: New to Filemaker need simple Script
            MacMak

            Got it to work great thank you!

            I have a new issue now is that I have an image container and I need to create an upload image button that will allow users to upload images straight into the container field. The button I have now works but only in edit mode.

            Thank again Phil for your help!

            • 3. Re: New to Filemaker need simple Script
              MacMak

              Also I need to create pagination at the bottom of my layout that will display the record that I am in but also will allow users to type in the record number they want and go to it by hitting enter.

              Your help is greatly apprecated!

              • 4. Re: New to Filemaker need simple Script
                philmodjunk

                Is this a database published to the web with Instant Web Publishing? If so, there is no easy or inexpensive way to do that for users who use a web browser to access the database. I believe that a third party produced product: SuperContainer can make this happen, but it isn't cheap.

                If your are using a stand alone database or one that is hosted for access by FileMaker Pro or Filemaker Go users, then your button should work as long as you use a container field and have it present on the layout when the script performed by the button executes.

                Is "record number" the number of the current record's position in the found set or a number that uniquely identifies that record with the same value no matter how you sort your records?

                If this is the record's current position, you can define an unstored calculation field, cRecordNumber as Get ( RecordNumber ). Make sure that you click the storage options button and specify that this calculation be unstored.

                Place this field on your layout. Then define a global number field. (Specify global storage in field options) and place it on top of your first field, formatted to be transparent.

                Write this script:

                Go To Record/Request/page [no dialog ; YourTable::YourglobalField]
                Set Field [YourTable::YourGlobalField ; ""]

                The second script step clears the global field.

                Now set an OnObjectSave script trigger on this global field to run the above script.

                If you haven't much experience in scripting, you may find these instructions helpful: 

                When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.

                • 5. Re: New to Filemaker need simple Script
                  MacMak

                  Hi Phil.

                      Thanks again for your help. My 2 prior questions were not related however and I apologize for the confusion. One was just about how to insert youtube video into layout to play and the other was to make a simple pagination so I can jump records by typing in the record number as in the same function as the top left on the menu.

                  I do however have another set of questions as well I hope you can help with. 

                  1. I have set up a drop box with values and I would like to have the values static so nobody can also type in their own text. Is that possible?

                  2. I need to make a calculation which is an average of several fields. Hope you can help with this as well.

                  Thanks again Phil for all your help!

                  • 6. Re: New to Filemaker need simple Script
                    philmodjunk

                    1) What do you mean by "drop box"? Is this a drop down list? Only users with full access can modify the values in a custom value list unless you specifically allow them too. You can use Manage | Database | Fields to find this field and double click it to open Field options. One option is a validation rule that limits the values in the field to only those listed in the drop down list's value list. You can also change it from drop down list to pop up menu to prevent typing other values into the field.

                    2) Are these several fields in the same record, a related table or an average of the same field for multiple records in the current found set of records? All are possible, but the implementation details vary.

                    Average ( Field1 ; Field2; Field3 )

                    computes the average for three fields in the same record.

                    Average ( RelatedTable::Field )

                    computes the average for a field in a set of records in a related table that are linked to the current record.

                    There's also a summary field that can be set to compute the average of a field. This can be used to compute the average for all or some fields in your current layout's underlying table or it can compute the average for a set of related records much like the previous example, but can also work with portal filtering.