1 2 Previous Next 17 Replies Latest reply on Jul 7, 2017 4:58 PM by gofmp15

    help in Filemaker Card Window

    thong127

      Hello All,

       

      Just install FMP advanced 16. I want to add records using filemaker window card but I cant make it work.

      Please help me.

       

      I have attached the sample file that Im working.

       

      Thank you in Advance.

       

      LoLa

        • 1. Re: help in Filemaker Card Window
          Jason Wood

          Looks like you intended to have global fields on your "Inventory Entry" layout.

           

          Also the "Save" script will need to start with a New Record script step.

           

          Also the "Save" script is not referencing the global field for "Release Date"

           

          Lastly, the Material ID field should not appear on the "Inventory Entry" layout.

          1 of 1 people found this helpful
          • 2. Re: help in Filemaker Card Window
            gofmp15

            Piece of cake...you forgot something in your script

             

            New Window..

            NEW RECORD...

             

            When you want a new record you have to add this step to the script or do it manually using Command+N or put a button on the card layout...

            • 3. Re: help in Filemaker Card Window
              Jason Wood

              And the "Cancel" script should not have a "Delete" script step, since no record was ever created. It would be deleting an existing record.

              • 4. Re: help in Filemaker Card Window
                Jason Wood

                gofmp15 wrote:

                 

                Piece of cake...you forgot something in your script

                 

                New Window..

                NEW RECORD...

                 

                When you want a new record you have to add this step to the script or do it manually using Command+N or put a button on the card layout...

                There are 2 basic methods, either you create the record after creating the card, and use regular fields, or use global fields and then create the record when you save. The basic reason your system is failing is because you're employing a mix of those two methods and you do not create a new record at all. Since you already have the global fields setup, I'd use this method (create the new record on save).

                • 5. Re: help in Filemaker Card Window
                  gofmp15

                  There are no global fields on the card window layout...

                   

                  This would seem to be the problem. The fields are regular fields but the script is trying to use global fields.

                   

                  Change the fields on the card layout to global fields and try again.

                   

                  Or use my technique of new record with the existing layout.

                  • 6. Re: help in Filemaker Card Window
                    keywords

                    Yes, I think Jason has nailed it. The global fields should be on the card window layout for the Save script to have any meaning—

                    Screen Shot 2017-07-02 at 2.06.33 PM.png

                    Each of the four data entry fields should be the global version. Suggest you also remove the ID field. And, as mentioned by others, you need to start your Save script by creating a new record.

                    • 7. Re: help in Filemaker Card Window
                      thong127

                      Hello All,

                       

                      Thank you for the replies, I was able to  fixed the problem. but two problem is arise. When I will create a new record, the values of my global fields of the last record created is still there.

                       

                      I put also an edit button but when I save it will create a new record and If I click my cancel button it delete my record.

                       

                      attached also is the file that I fixed.

                       

                      !Thank you for the help.

                      • 8. Re: help in Filemaker Card Window
                        Markus Schneider

                        Global fields are for all records, per user, per session - means, that they keep the data

                         

                        On a local file, the contents of global fields will be there even after a restart of FileMaker

                         

                        It's up to the develeoper to deal with that, means that You have to 'empty' those fields after usage (or before..)

                        1 of 1 people found this helpful
                        • 9. Re: help in Filemaker Card Window
                          gofmp15

                          Glad I could help by pointing out that the fields on your new window layout are not globals.

                           

                          Change them to globals and make this your script:

                           

                          Set global field to ""  For all of the global fields

                          New Window

                           

                          Now the global fields are empty. If you do this BEFORE you open the window they will always be empty on your layout.

                           

                          As others have pointed out, when using GLOBAL fields on the layout, the ID field is not needed and meaningless. It will be filled in when you create the new record.

                           

                          Generally speaking it is always a good idea to set globals like this to empty in the script that opens the new window rather than hoping they have been emptied elsewhere.

                           

                          And don't forget to put the GLOBALS on this type of layout/script rather than normal fields.

                          • 10. Re: help in Filemaker Card Window
                            keywords

                            thong127 wrote:

                            two problem is arise.

                            When I will create a new record, the values of my global fields of the last record created is still there.

                            To fix that you could add further steps to your Save script, so that once the global values have ben transferred to the real fields, you clear them: Set Field [ <name of global field> ; "" ], repeated for each of the four global fields.

                            You could also create a separate script using just these clear the globals steps, which is triggered each time you go to the card layout. This will ensure that whenever this layout is opened the fields on display will be empty.

                            I put also an edit button but when I save it will create a new record and If I click my cancel button it delete my record.

                            Although the edit script might use the same layout it cannot use the same script in exactly the same way. You edit script should do the following:

                            Go to the card window layout

                            Isolate the record you want to edit

                            insert the existing values of your fields into the relevant global fields on this layout

                            set some sort of flag (probably a global variable—e.g. $$editRecord, which is set to 1) to indicate (to your next script) that they are editing an existing record rather than creating a new one.

                            end of script

                            The script will look something like this:

                            #—script sets up the edit process but doesn't complete it

                            New Window [ Style: Card; Name: "Data Entry"; Using layout: “Inventory Entry”; Close: No; Minimize: No; Maximize: No; Resize: No; Menu Bar: No; Dim parent window: Yes; Toolbars: No ]

                            Find Matching Records [ Replace; Inventory::MATERIAL ID ]

                            Set Field [ Inventory::g_Material Name; Inventory::Material Name ]
                            Set Field [ Inventory::g_Material Lot Number; Inventory::Material Lot Number ]

                            Set Field [ Inventory::g_Expiry date; Inventory::Expiry date ]

                            Set Field [ Inventory::g_Release Date; Inventory::Release Date ]

                            Set Variable [ $$editRecord; Value:1 ]

                            Exit Script [ ]

                             

                            If you do this, the user who tries to edit an existing record, when the card window opens, will see the values in the record they were just looking at and can then edit what the see there. They will in fact be changing the global field(s) at this stage. You will need to amend your Save script so that it doesn't create a new record if that is what you are doing. The script could have a conditional loop around the New Record step:

                            If [ $$editRecord 1 ]

                                      New Record/Request

                            End If

                             

                            When they click the Save button the script will only create a new record if the $$editRecord value is not 1. This means that if you are editing an existing record the rest of the script will replace the values with the new values entered into the global fields.

                            The Save script will now look something like this:

                            #—the conditional step below will run only if the global variable has been set

                            If [ $$editRecord 1 ]
                                
                            New Record/Request

                            End If

                            #—clear the global variable now that you don't need it any more

                            Set Variable [ $$editRecord; Value:"" ]

                            Set Field [ Inventory::Material Name; Inventory::g_Material Name ]

                            Set Field [ Inventory::Material Lot Number; Inventory::g_Material Lot Number ]

                            Set Field [ Inventory::Expiry date; Inventory::g_Expiry date ]
                            Set Field [ Inventory::Release Date; Inventory::Release Date ]
                            Commit Records/Requests

                            #—clear the global fields now that you don't need them any more

                            Set Field [ Inventory::g_Material Name; "" ]
                            Set Field [ Inventory::g_Material Lot Number; "" ]

                            Set Field [ Inventory::g_Expiry date; "" ]
                            Set Field [ Inventory::g_Release Date; "" ]

                            Close Window [ Current Window ]

                            Exit Script [ ]

                             

                            1 of 1 people found this helpful
                            • 11. Re: help in Filemaker Card Window
                              gofmp15

                              While informative, this does not match what the questor is doing.

                               

                              He is opening a card window and did not place global fields on it, hence his problems. To gaurantee that the globals are empty it is best to clear them when the window opens.

                               

                              His script to open the card window should be:

                               

                              Set field (globals; "" ) for each global

                              New card window

                               

                               

                              His save button : was scripted correctly

                              New Record

                              Set Field (x; global field x)

                              etc

                              Commit Record.

                               

                              The Cancel Button simply closes the window and need not do anything.

                               

                              I recommend clearing the globals in the new window script to insure they are empty which you could verify by looking at the field.

                               

                              Two scripts are simpler to maintain than using flags and variables and parameters and easier to understand and explain for new users.

                               

                              Everyone has a different approach and what works works.

                               

                              Also note that the global fields do not have to be in the table in which the record is to be created.

                               

                              A global field table could be used and the save script

                              Freee window

                              Go go to the table

                              set fields

                              commit record

                              close window

                              • 12. Re: help in Filemaker Card Window
                                keywords

                                My response was to the OP's later post which contained two specific questions.

                                • 13. Re: help in Filemaker Card Window
                                  thong127

                                  Hello All,

                                   

                                  I made A script I Called it (Clear Globals) to Clear my Global Fields so that when I click my add entry button will clear the contents of my global fields but when I click my save button, I cant see the records that I created.

                                   

                                  Clear Globals Script:

                                   

                                  Set Field [ Inventory::g_Material Name; "" ]
                                  Set Field [ Inventory::g_Material Lot Number; "" ]

                                  Set Field [ Inventory::g_Expiry date; "" ]
                                  Set Field [ Inventory::g_Release Date; "" ]

                                   

                                  Save Script

                                   

                                  Perform Script Clear Globals

                                  Set Field [ Inventory::Material Name; Inventory::g_Material Name ]

                                  Set Field [ Inventory::Material Lot Number; Inventory::g_Material Lot Number ]

                                  Set Field [ Inventory::Expiry date; Inventory::g_Expiry date ]
                                  Set Field [ Inventory::Release Date; Inventory::Release Date ]

                                  New Record/Request

                                  Close Window Current Window

                                   

                                  Thank you in advance.

                                   

                                  LoLa

                                  • 14. Re: help in Filemaker Card Window
                                    keywords

                                    Did you read and understand my last response?

                                    1 2 Previous Next