3 Replies Latest reply on Mar 22, 2011 9:45 AM by philmodjunk

    Create New Record using a Dialogue Box

    xxx202xxx

      Title

      Create New Record using a Dialogue Box

      Post

      I have a table called "assets" on occasion I need to create new records.  Currently I have a button called "new" that I click to create the new record and which is set to assign a unique identifier.  Here is my problem that I need assistance with, I want to force techs to verify that their data (on the "asset layout") is correct prior to submitting the record or they can either cancel the request to fix their data or they can simply cancel the request all together.  All of my attempts have failed with several created records with unique identifiers.  I would like to use a dialogue box for the technicians to select the "submit", "back" and "cancel" buttons that would manipulate the record creation or cancellation.

        • 1. Re: Create New Record using a Dialogue Box
          philmodjunk

          Let's start with Show Custom Dialog.

          This option works if you only need them to enter 3 or fewer items when creating the new record.

          Define a global field for each. (Select global storage options)

          Use a script with this pattern:

          Show Custom Dialog ["enter data for new asset record."]
          If [ Get ( LastMessageChoice ) = 1 //OK button was clicked]
             //put code here to check each value to make sure that it is OK if you need to
             //exit script and show a dialog telling the user about the error. If no error...
             New Record/Request
             Set Field [Assets::field1 ; yourTable::globalfield1]
             Set Field [Assets::field2 ; yourTable::globalfield2]
             Set Field [Assets::field3 ; yourTable::globalfield3]
          End If

          The key detail, is that by capturing the data in global fields, you don't have to create a new record unless the data entered is both valid and if the user does not click the cancle button in the custom dialog.

          A more userfriendly option is to use the New Window command to pop up a new window. This option allows you to set up a small Filemaker Layout complete with value lists and validation checks to help catch and correct errors. You can also have more than just 3 input fields. It does take more scripting to support, however, especially on windows platforms if your windows are kept maximized. If you want to pursue this option, let me know and I can provide more details and a download link to a file that uses new window to pop up "dialogs" for user input.

          • 2. Re: Create New Record using a Dialogue Box
            xxx202xxx

            I think I would like more information on the alternative solution.  It will be difficult to justify only 3 fields to base their decision on.  They will need to populate multiple fields that may have errors.  Once the entire form is completed only then should they submit or cancel or cancel without restrictions.

            • 3. Re: Create New Record using a Dialogue Box
              philmodjunk

              Mac System, Windows or both?

              The New Window script step can open a new window with window name, size and postition specified by you.

              You can then use go To Layout to bring up the desired layout where you have set up your global fields for capturing the data to be entered for the new record.

              Then you do this:

              Allow User Abort [off]
              Loop
                 Pause/Resume [indefinitely]
              End Loop

              Use a "Save" button to then run a script that creates a new record and transfers the data from the global fields to the matching fields in the new record. Use a "Cancel" button to just close this window.

              Set up both buttons with the Halt script option to terminate the infinite loop in the script that opens this window. (You can also make Halt Script the last step of the scripts performed by these buttons to get the same result.)

              The infinite loop simulates modal dialog behavior by making all other FileMaker windows unresponsive to the user. They won't even be able to close the window by clicking the close box. They'll have to click a button you put in the window to do that instead. (If you want the close box to work as a "cancel" action, you can use FileMaker Advanced and a custom menu to set up a close window script in place of the normal close window option in the File Menu.)

              Warning, leave out or disable the allow user abort step when you first test these scripts. Unless you have FileMaker Advanced, failure to implement the scripts correctly can trap you in a loop that you can only exit by force quitting FileMaker--which can damage the file.

              Here's a download link (click the blue down load button) to a file that uses such floating windows for user input.

              http://www.4shared.com/file/8orL8apk/FMP_Bugs.html

              The New button on the first screen is probably the simplest, most straight forward example. The scripts check to see if the current platform is windows and if so, includes additional steps to keep the original window from resizing any more than absolutely necessary. This resizing glitch only occurs on windows systems and then only if the windows have been "maximized".