6 Replies Latest reply on Jun 10, 2010 9:32 AM by ianmanning

    How to maintain current status after a change and save (commit)?

    WMMike

      Title

      How to maintain current status after a change and save (commit)?

      Post

      I'm fairly new to Filemaker/scripting, so excuse me if I ask the obvious. I've got a problem wtih a script/layout. My script presents an overview a club members, conditional to whether tthey have paid thier club dues in a certain period. Simple, presenting the contents a table (call it table1). It works fine, no problem. But in another table in the database (table2) I store totals for the given period. My layout is designed to also display the totals from this table (table2) and that works fine too. The problem is that when I save the totals to table2 (using a commit step), the saved record ceases to be current and table2 reverts to the first record. This causes my totals to disappear on the layout. I need to be able to save the record to table2 and also for the record to remain current so the appropriate field values are presented on the layout. Is this possible?

       

      Thanks,

       

        • 1. Re: How to maintain current status after a change and save (commit)?
          ianmanning

          I may be missing something very obvious but failing that you could add steps to your script

          to capture the current record number you are editing "Get(RecordID)"  and then after commiting the record go back to that record in the next step. Go to Record/Request/Page[...]

           RecordID is a unique record identifier

          (Get(RecordNumber) RecordNumber is the nth record in the found set.

          if your script changes the found set then you need to use RecordID and add Show All Records to the script as the Go to Record/Request/Page[...] goes to the nth record in the found set.

           

          Set Variable [$CurrentRecordID; Value:Get(RecordID)]

          Commit Records/Requests[no dialog]

          Show All Records

          Go to Record/Request/Page[$CurrentRecordID]

           

          I hope this points you in the right direction, Im sure others will have more ideas for you.

          Regards

          Ian

          • 2. Re: How to maintain current status after a change and save (commit)?
            WMMike

            Ian,

             

            thanks for your suggestions. It just hasn't worked out, primarily because the RecordID is only unique in the given set and is not unique in an absolute ('key") way. The record it locates depends on its value within the current found set or table that is being processed. In my case the record I need is in another table.

             

            In my script I first process the member table (table1). The found members (selected with a Perform Find step) are then displayed using the layout. The trigger record in table2 (table2 has no direct relationship with table1) is the holder of the job parameters for processing table1 and also the place I want to save the totals. So I end up with a layout which displays fields from table1 (multiple records) and also a couple of fields from 1 record from table2. Because table1 and table2 are not directly related it's hard to hold them both "current" on the layout.

             

            What I need to do is to "get" at that one record in table2 without disrupting the "current" found set, which is what I have on display in the layout. Is it possible to first stipulate the 'target' table (table2 in my case) and then use the RecordID to identify the record needed within the table? If that is possible, I think it would work.

             

            Or is my thinking incorect? Maybe there's another way for Filemaker to create records in a table separate to the table being processed?

             

            Thanks again for your interest and expertise,

             

            Mike  

            • 3. Re: How to maintain current status after a change and save (commit)?
              ianmanning

              Could you add a key field to each table then add both keys to variables, complete/ commit your records then find both records again using the keys or their RecordID in each table.

              Is there no way of building a relationship between the two tables?

              You could tag the found records with a simple 1 or 0 field entry using the replace field contents (having cleared all the records before the initial find or as the last step in the script) you can then easily refind all the previously found records without having to recreate a complex find structure. This can be done for both tables.

               

              ie build your found set of records

              set foundRecord field to 1 in both tables using replace fields contents

              commit records

              perform find on each table using foundRecord field = 1

              switch to your preferred initial layout

              finally set foundRecord field to 0 on all the found records ( ready for next time)

               

              I hope one of these may give you some ideas.

              Regards

              Ian

               

               

              • 4. Re: How to maintain current status after a change and save (commit)?
                WMMike

                Ian,

                 

                thanks for the ideas. I'll try the stuuf out and let you know.

                 

                Cheers,

                 

                Mike

                • 5. Re: How to maintain current status after a change and save (commit)?
                  WMMike

                  Hi Ian,

                   

                  i've got it working, thanks to a mixture of your suggestions and a little bit of experimenting. It actually great fun playing with the possibilities and a great way to learn filemaker.

                   

                  Thanks again,

                   

                  Mike

                  • 6. Re: How to maintain current status after a change and save (commit)?
                    ianmanning

                    My Pleasure.

                    It never fails to amaze me what you can achieve with filemaker and combinations of scripts, layouts, relationships and formatting.

                    Have fun learning

                    Best regards

                    Ian