9 Replies Latest reply on Jan 31, 2011 4:52 PM by kimme

    Script for save button

    kimme

      Title

      Script for save button

      Post

      I am trying to create a form where user can input data and needs to click on the save button before the records will be saved to the database. I am trying to do it that way because I have a field that will calculate the total amount and another field for signatories which depends on the total amount to be calculated. Currently, there is delay in the process since those fields needs to be clicked everytime there's changes in the form.

      example:

      If the total amount is greater than 100k then the signatories will include vice-pres and president else it wont.

       

      I was planning to create a button that will finalize the form by creating a save button. but im not sure how to create a script that will pass the values to the database. please help.

      (im newin filemaker and im new here; hoping to resolve this problem :-(

        • 1. Re: Script for save button
          Abhaya

          hi,

          For user form  you should make all the fields global. Then  write a script ...

          set al the fields from the form view

          then go to the parmanent table

          set corresponding fields

          then commit record

          this script must be aded with the save button.

          try it......

          • 2. Re: Script for save button
            philmodjunk

            Or you may be able to go to layout setup, turn off the auto-save feature, and give your Save button this script step: Commit Record.

            To keep clicks on the layout background from triggering the commit record, place an empty web viewer with invisible borders behind all your other layout objects so that it intercepts all such mouse clicks.

            • 3. Re: Script for save button
              kimme

              Hi all:

              Thanks for the help.

              I got it now working, I just had my SAVE button working now with the empty web viewer at the back of all fields.

              My next problem for this project is that I'm trying to filter the entries. I am trying to do an If script but it doesn't seem to work.

              I have 3 types in this form (1)Stock, (2) Non-Stock and (3) Service. I also have 2 required account fields whenever user selects Non-Stock and Service. If Stock,then they can proceed with saving the form. Otherwise, they can't save the form.

              Please help.

              • 4. Re: Script for save button
                philmodjunk

                I have 3 types in this form (1)Stock, (2) Non-Stock and (3) Service. I also have 2 required account fields whenever user selects Non-Stock and Service. If Stock,then they can proceed with saving the form. Otherwise, they can't save the form.

                Why would you want to prevent saving the data if they enter non-stock or service? That makes no sense to me.

                • 5. Re: Script for save button
                  kimme

                  those 2 accounting fields are required fields for non-stock and service. That's why when user selects Non-Stock/Service they should not be able to save the form if the accounting fields are empty.

                  • 6. Re: Script for save button
                    Frinholp

                    Hi Kim

                    Assuming you have a basic kwoledge of scripts, IF 'isEmpty' is the function I thing you are looking for.

                    Your final goal on this matter is not too clear right now, but I assume if there is no entry in the stock field, you will be unable to commit the record? 

                    If [ isEmpty (TableName::StockField) ]

                    Commit Records/Requests

                    Endif

                    You could also add an Else statement to throw a dialog box which states the required fields to commit the record, have not yet been completed.

                    Any further questions ask

                    Lee

                    • 7. Re: Script for save button
                      kimme

                      Hi Frin,

                      Thanks for the help. Im not too familiar with scripts in filemaker.

                      I tried the isEmpty statement, tried it in one field but it can still proceed saving the form even having empty field. Do I have to do something else for this to work?

                       

                      What I am trying to do is not allowing users to save the form when there are incomplete fields. Specifically, not allowing them to save if the accounting fields are empty.

                      • 8. Re: Script for save button
                        Frinholp

                        Hi Kim

                        I'm assuming your script is pretty small. It would assist me in devising a solution if you could post your script steps.

                        I tried the isEmpty statement, tried it in one field but it can still  proceed saving the form even having empty field. Do I have to do  something else for this to work?

                        If a field holds no data, isEmpty ( field)  will be true and will continue executing the script enclosed in the if statement brackets.

                        If there are required fields to be filled you need to use not isEmpty (field1) or not isEmpty (field2) etc as the condition of executing the script steps within the if statement (One script step being commit record I assume?).

                        Also if you use ELSE  after the IF the you can use Exit Script. This will terminate the script when the condition in the IF statement is not met. This may be good practice for the future.

                        In the ELSE section, before Exit Script is executed you may also want to display a dialog to let the user know why the record has not commited.

                        I have made quite a few assumptions here. As I say, post your script contents so I am able to guide you further if necessary. 

                        Remember there are many ways to skin a cat so the above suggestion may not be the most efficient solution.

                        Lee

                        • 9. Re: Script for save button
                          kimme

                          Hi Lee..

                          Yehey! Got it working ^_^ thanks for the help. There are things I want this form to become, still trying to figure out how to make it work in filemaker.

                           

                          Thanks also to PhilModJunk and Abhaya Behera for the help. :)

                           

                          Regards,

                          Kim