1 2 Previous Next 18 Replies Latest reply on Feb 3, 2012 11:36 AM by JohnNekrews

    Problem with Script Manager, or is it me?

    JohnNekrews

      Title

      Problem with Script Manager, or is it me?

      Post

       I'm having a major problem trying to setup a simple script using Script manager (FMP11A).

      I want to set up a simple straightforward script to reset the contents of a field thus ;- Set Field [T_Cal::Run#; 1]

      This should be so, so easy, but after I select the action (Set Field) then specify the table::field (T_Cal::Run#), that's as far as I can get, FMP won't allow me to manually add the '; 1' and provides no other way for me to edit the script.

      Wow!, this learning curve is helluva steep.

      Nik

        • 1. Re: Problem with Script Manager, or is it me?
          mgores

          In the set field step, there are two options.  One which you have found it to define the target field.  The other is Calculated result, this is where you would enter your "1".

          • 2. Re: Problem with Script Manager, or is it me?
            JohnNekrews

             Thanks Mark, that works a treat.

            It was the quotes that threw me as it is a numerical field I wanted to reset to 1.

            Unfortunately it hasn't solved  my underlying problem of an overal record count still including deleted records.

            Any advice on this aspect?

            Nik

            • 3. Re: Problem with Script Manager, or is it me?
              mgores

              For a count of current records, you could use the Get (current record count) function.

              • 4. Re: Problem with Script Manager, or is it me?
                philmodjunk

                Describe what you mean by "overall record count". The count of records shown in the status area should update correctly when you delete one or more records, so I must assume that you are looking at some other record count or expecting that record count to reflect the number of records in a different table than that specified for that layout in the "show records from" drop down in Layout Setup.

                • 5. Re: Problem with Script Manager, or is it me?
                  JohnNekrews

                   Phil & Mark,

                  Tks again for your input.

                  My problem is that each database table has a 'Record No.' field which increments by 1 each time a record is added.

                  However, when a record is deleted, this field still counts it. e.g. The forst record isn't a problem, but if, when entering a second record, it is deleted for whatever reason, the next record will be #3 even though there are only 2 records in the database.

                  That is the problem I am trying to overcome, can either of you help, or is this a characteristic of FMP that I'm gonna have to live with?

                  Nik

                  • 6. Re: Problem with Script Manager, or is it me?
                    philmodjunk

                    Why is it a problem?

                    Gaps in the number series usually aren't something that causes any problem. Which value is entered next in an auto-entered serial number is controlled by a next serial value property that can be reset by script, but I don't recommend that you do this unless you have a very good reason to do so. (And this only works if the record with the largest ID number is deleted.)

                    There are a number of ways to display lists of numbers with gap free sequence numbers (display purposes only) and also ways to count the number of records in your table or found set that do not require a perfect numbering series to do so.

                    • 7. Re: Problem with Script Manager, or is it me?
                      mgores

                      There is a difference between the count of records and the serial number.  As Phil said, a gap in serial number is not an issue and can cause problems if you try to override it.  It is better to have a separate field for record count, which you can get using a calculation for display purposes.

                      Any relationships should be based on the autoentered serial number though.

                      • 8. Re: Problem with Script Manager, or is it me?
                        JohnNekrews

                         OK Phil,

                        Tks for that, a valid point indeed.

                        I guess that I'll have to approach this project from a different angle.

                        I have yet to discover a function, or script, which will provide an accurate count of records in a table.

                        Nik

                        • 9. Re: Problem with Script Manager, or is it me?
                          JohnNekrews

                           Tks Mark,

                          Your post came in just as I was responding to Phil.

                          As you can probably tell, my experience with Db programming is extremely limited, and of course, whatever Db applications I've played with in the past differ vastly in available functions and scripting syntax. It makes the learning curve so much steeper, but thanks to the likes of you, Phil and numerous others, I am getting there, albeit painfully slowly.

                          Thanks again to all you guys (and gals) who give up theeir valuable time to assist people like me.

                          Nik

                          • 10. Re: Problem with Script Manager, or is it me?
                            philmodjunk

                            Look up the get function in FileMaker help. This is a swiss army knife kind of function that can be used to tell you many different things about your database depending on which parameter you specify.

                            To count the records in the current layout's found set: Get ( FoundCount )

                            To count the total records in the current layout's table: get ( TotalRecords )

                            To count the number of records in a  related table that are related to the current record in your layout: Count ( RelatedTable::NeveryBlankField ). You can also use a "count of" summry field from the related table to get the same count.

                            To count the total records in a different table a) use a script to change to a layout based on that table and use Get ( totalRecords ) to count them. or b) set up a relationship based on X instead of = and use one of the two methods for counting related recors. (The cartesian join operater, X, sets up a relationship that matches to all records in the related table.)

                            • 11. Re: Problem with Script Manager, or is it me?
                              JohnNekrews

                               Tks Phil,

                              I think I'm relying too much on the "FMP Design & Scripting for Dummies".

                              I may be a 'Dummy' but I'm not finding the book to be much help.

                              I find the official documentation to be so awesomely vast and so difficult to find specific information.

                              Your help, along with everyone else on the forum, is invaluable, and it's the only thing that keeps me plugging away at this marvellous, yet totally frustrating, piece of software.

                              Thanks again.

                              Nik

                              • 12. Re: Problem with Script Manager, or is it me?
                                philmodjunk

                                If you go to Help and enter "get" then click List Topics, then Click Display, you should be able to get a nice list of all permutations of the Get function. You can then click one to see the details on that specific combination of Get and parameter. I find myself checking this list often when I hit a challenge for which an immediate solution does not instantly come to mind.

                                • 13. Re: Problem with Script Manager, or is it me?
                                  mgores

                                  Yes, Filemaker can be like that.  It is marvelous in the things it can do, but sometimes frustrating in figuring out how to get it to do it.

                                  This forum, Phil is one of the best,  has saved me what little hair I have left many times.

                                  • 14. Re: Problem with Script Manager, or is it me?
                                    JohnNekrews

                                     Phil,

                                    I have created a field on my layout using 'Get (TotalRecordCount)' to display the total number of records in the associated table, and it works as expected.

                                    Except however, when I step through the records using button script 'Go to Record/Request/Page []', the field I created is incremented, or decremented as I step forwards, or backwards, through the records.

                                    Something, somewhere doesn't add up?

                                    Nik

                                    1 2 Previous Next