8 Replies Latest reply on Jul 12, 2017 2:26 PM by cmj

    Add Record Script with Dialog

    cmj

      I'm very new to scripts and require some direction on accomplishing a task.

      On my layout (not a portal), I've placed a button that will add a new record.

      When the user selects the button:

      I'm requesting a new record (I can do this)

      Going to a specific field that contains a drop-down (I can do this)

       

      At this point, I want dialog to tell the user to select from the drop-down. The dialog should remain in place until the record is selected. (no idea how to do this)

       

      Next, the cursor goes to another drop-down field (I can do this) and the dialog pops up again until the record is selected.

       

      After that I set various fields that relate to the choices made in the drop-down fields. (I think I can do this).

       

      Thank You

        • 1. Re: Add Record Script with Dialog
          fitch

          Dialog boxes are modal, that is, they prevent the user from doing other actions. So we can't build this exactly as you described.

           

          If you simply want to require that certain fields not be empty, you can specify that in the field's validation options (under Manage > Database).

           

          If your goal is to prompt the user, there are various ways to display a message on the layout -- for example using the "Hide object when" feature of the Inspector. This is generally a better user experience too. Most people find dialog boxes very annoying.

          1 of 1 people found this helpful
          • 2. Re: Add Record Script with Dialog
            cmj

            Thanks Tom. I tried this but the script does not pause until the drop-down selections are made. The issue is that the script needs the drop-down values prior to setting other related field values.

            I could use a second script that runs upon leaving the last drop-down field but the records in this layout are often created by manual entry (not using the button). In those cases I would not want the script to run upon leaving the last drop-down field.

            • 3. Re: Add Record Script with Dialog
              philmodjunk

              Try using a popover button.

               

              Your script can open a popover button with the value list formatted fields or fields inside the popover panel. Layout text placed in the same panel can instruct the user on what to do.

               

              Go to Object can open the popover.

               

              Your script can "pause" in one of two ways:

               

              Open the popover and that can be the end of the script. A "save" or "continue" button inside the popover can close the popover and perform a second script to do anything else that your script cannot do until these fields have had values selected for them.

               

              Open the popover and pause with the pause/resume script button. The "save" or "continue" button in the popover can be a single action button to continue the script or the user can click "continue" in the status tool bar if it is visible.

               

              I think the first option is less troublesome, but you can try both options and see which works best.

              • 4. Re: Add Record Script with Dialog
                cmj

                I'm using Ver 11. No pop-over available in this version?

                • 5. Re: Add Record Script with Dialog
                  philmodjunk

                  No, no popover in a version that Old. you should give very serious consideration to upgrading and for a lot more reasons than to get popovers.

                   

                  But using FMP 11, you could open a small window with these drop downs in it. Not nearly so nice and you have to make it modal with some scripted trickery, but it can be made to work.

                   

                  You might instead rethink this approach so that your dialog box with a pause isn't needed. You could, for example, take the user to layout #1 to select from the value list fields with no other fields on the layout, then take them to layout #2 to complete the process only after the first set of fields have been correctly filled in with data.

                  1 of 1 people found this helpful
                  • 6. Re: Add Record Script with Dialog
                    cmj

                    Nice idea about leaving the layout. I may give it a try. Also...I pasted a reply below that I found from an old post (your reply). Maybe this would work?

                     

                    Have the following code be the first part of the script performed/resumed by clicking your button:

                     

                    Loop

                       Exit Loop If [ ValueCount ( List ( Table::Field1 ;Table::Field2 ; Table::Field3 ) = 3 // all three fields have data ]

                       If [ IsEmpty ( Table::Field1 )

                          Show Custom Dialog

                       Else IF [ IsEmpty ( Table:::Field2 ) ]

                           Show Custom Dialog

                       Else

                            Show Custom Dialog

                       End If

                       Pause/Resume Script

                    End Loop

                     

                    The if and Exit If expressions can be be made much more sophisticated if necessary to check for more types of user input errors.

                    • 7. Re: Add Record Script with Dialog
                      philmodjunk

                      It handles the needed error checking, but if you want to display a message to the user at the same time, you may have issues depending on how much space on the layout itself you might want to use for this purpose.

                      • 8. Re: Add Record Script with Dialog
                        cmj

                        I'll give it a try and failing that, I'll go to an other layout to select the values needed.

                        Thanks!