5 Replies Latest reply on May 22, 2012 11:00 PM by philmodjunk

    Minor things I'd really like to know how to do in FileMaker

    PeterThorton

      Title

      Minor things I'd really like to know how to do in FileMaker

      Post

      Hello,

      this is just a few things I've encountered while creating a user interface in FileMaker, that I haven't been able to figure out yet. I'll just list the ones I can think of right now, hopefully they'll be easy to answer for you FileMaker pros.

      First of all I should explain that I do a lot of buttons and scripting, users pick related record through search layouts and list layouts launched by clicking a button.

      My first problem is, depending on what is done on those related layouts, when the user navigates back to the original layout, sometimes the record displayed on that layout has changed. I'll give you an example:

      We have a table of customers (called BusinessPartner), some of those customers happen to be dealers. They are in the same table, because from our point of view they're essentially the same, regardless of whether they're a dealer or a customer. But we do need to track which customers are dealers, and which customers they deal to. So there's a join table between a dealer and a customer (which is essentially a join table between BusinessPartner and BusinessPartner).

      Now let's say I have a customer with ID 1, displayed in my CustomerManagement layout. He's a dealer, and I want to assign a related customer to him. I click a button, FileMaker takes me to a searchbox layout and enters find mode. I do my search, and a list of all the customers that match the search criteria is brought up. I click on customer with ID 17, and an entry in the join table is created. Up until this point it works perfectly. But when I get back to the CustomerManagement layout, the customer displayed there is number 17, instead of number 1. How do I prevent this, or if this us unaviodable, how do I navigate back to my original customer? (the ID is accessible in the scripts, shouldn't be too hard)

      Furthermore, there's a tab control on my CustomerManagement layout, and the 'related customers' tab happens to be the last one. But when I get back to the layout, the selected tab is the first tab. So the user has to manually navigate to the correct customer, and then the correct tab, just to see the results of their latest addition. How can I solve this?

      The second problem is, how do I make some controls uneditable? As I mentioned, I need my users to enter data in a specific way, to ensure correct functioning of the solution. If they click in a field they're not supposed to, and edit the data, they can cause serious havoc in the database. I've played around with this issue, I've discovered that if I set the control up as a button and assign an empty script to it, it seems impossible to selct the text inside it by cliking it. The field can still be selected using the tab, but I solved that by removing it from the tab order. Is that it? Is there no other way of selecting and editing the field this way? Is there a more straightforward way of doing this, or is this workaround the only thing I can do?

      Third problem: Can I disable or enable certain features of the user interface based on values in some fields? For instance I have a Yes/No field in my customer table that determines whether or not he's a dealer. If the field is set to No for a particular customer, I want the 'Add related customer' functionality to be disabled.

        • 1. Re: Minor things I'd really like to know how to do in FileMaker
          GuyStevens

          To go to a certain tab:

          You give the tab a name and then in your script you use the GoToObject script step. The object you go to is the name of the tab.

           

          To go back to the original contact:

          In the first script you could set a global variable. That is a variable that remains available after your script is done, and thus can be used later in another script. You do this by putting two dollar signs in front og your variables name.
          So you "Set Variable" - $$OriginalContact

          In the end of your last script you:

          GoToLayout (Your contacts layout)
          Enter Find Mode // clear the pause
          Set Field - Set your Contact ID field to the value of "$$OriginalContact"
          Perform Find
          Then you add your GoToObject "Tab Name"

          Voila.

          Question: How do you set the related contact in your join table? Because if you do not go to your contacts table your record doesn't change. If you get the ID of the related contact from your Adress table and you set a new record in your Join table your contacts table should not have changed.

          Also you could use GoToRelatedRecord depending on which table you are in. If you are in your join table to set the original contacts Id (1) and the linked conta'ct id (17) then you could go to related record based on your contact table in the layout of the contact. You would arrive at contact 1.
          If, in this situation, you would go to the related record of the second TO of the contact table (the table occurrence of the linked contact) on the contact layout you would arrive at contact 17

          To make a field uneditable

          In the inspector under Behavior - Field Entry: uncheck Browse Mode. That way that field is not editable in browse mode.

           

          Conditionally deciding when a field can be edited.

          You can do a lot in "File" - "Manage" - "Security"

          If you create a privilege set for your users you can use calculations to decide whether a record is editable or not.
          But you could also use scripts on fields that are set to trigger "OnObjectEnter" so that wen you enter a field the script can check maybe a different field to see if it has been filled in or not.

          A script could be:

          If [IsEmpty (Table::Field)
            Show Custom Dialogue [Please fill in the Field first]
            GoToField (Table::Field)
          End If

          • 2. Re: Minor things I'd really like to know how to do in FileMaker
            GuyStevens

            About the yes / no field of the dealer. You could add to the "Add related Customer" button script: (in the beginning)

            If [YourTable::Dealer = "No"]
              Show Custom Dialogue [You can't add a related customer because this customer is not a dealer!]
              Halt Script
            End If
            Here you write all the script steps you do want to do to create a new dealer.

             


            This way you won't be able to create a related customer when the dealer field is set to no.

            • 3. Re: Minor things I'd really like to know how to do in FileMaker
              philmodjunk

              My first problem is, depending on what is done on those related layouts, when the user navigates back to the original layout, sometimes the record displayed on that layout has changed

              Layouts that refer to the same exact table occurrence (box in manage | database | relationships) in "Show Records From" as found in Layout setup, will share the same found set, current record and sort order. Changes to the found set on a given layout will affect what you see on all layouts that have the same table occurrence.

              If you open Manage | database | relationships, select a table occurrence and click the duplicate button (two green plus signs), you will get a copy of that table occurrence that refers to the same table as the first. If you select this new table occurrence in "Show Records From" for a given layout, you can perform finds, change the sort order, etc and these changes will not appear on other layouts that still refer to the original table occurrence. Please note that you will need to update each field on your layout if you do this and any portals or other references to related tables will not work as you are now based on this new occurrence of your original table.

              • 4. Re: Minor things I'd really like to know how to do in FileMaker
                PeterThorton

                About making the fields uneditable under certain conditions:

                I have a portal on my Order layout that shows the order lines. I have three fields next to each other:

                Items per box,

                No. of boxes,

                Amount

                the first two are only relevant if the item in question is a box. I've made all the fields except Amount uneditable, so the user can only input the amount of items.

                In case of packages, the Amount should be equal to (Items per box) * (number of boxes), and I plan to add a script that will calculate this.

                But as I discovered that this is a bit confusing. If you're entering the Amount for a box, you'd expect 'Amount' to mean number of boxes. Even if you're the guys who knows that 'Amount' means total amount of items in boxes, because you designed it that way. Also, if you have boxes of 10, and the user inputs 15 in the Amount field, the No. of boxes would have to read 1.5, which is no good, you're supposed to put either whole boxes on orders, or separate products.

                Editable and uneditable fields are visually distinguished (editable are white and uneditable are lilac, this color was specifically requested by my boss). So I can use conditional formating to flip the colors. But I'd also like to be able to conditionally determine if the field should be editable. Ideally I'd like to get at the Data -> Behavior -> Field entry and check/uncheck Browse mode. Is that possible? I guess not. In that case I'll have to make do with a script, launched by say, a OnObjectEnter script trigger, that will tell the user off if he tries to click on the field that's not supposed to be editable. The problem is, what to do after the Dialog is displayed? The user has been told not to edit the field, but the focus and the cursor is in the field and they can type freely. How can I tell FileMaker to prevent the user from editing the field?

                • 5. Re: Minor things I'd really like to know how to do in FileMaker
                  philmodjunk

                  In your script, don't display a message, just use go to field or go to next field to put the cursor in a field that can be edited when the field in question should be locked.