12 Replies Latest reply on Sep 20, 2014 8:38 AM by LanceMendoza

    How to insert data into a records set

    LanceMendoza

      Title

      How to insert data into a records set

      Post

      Im developing a solution in filemaker 13 and im having problem inserting a data to a field.

      Current Month: September

      Month           | Name                                    | Payment
                           |  Juan Dela Cruz                    | 430 
                           | Nerissa Bascos                     | 420
                           | Noel Pagot                            | 445

       

      I would like to Auto insert September in the Month Field. Is there any way i can do that. I not good in Filemaker scripting. What should i do if i have 50+ names and i need to insert "September" in every month field automatically. Thanks for your help.
       

        • 1. Re: How to insert data into a records set
          philmodjunk

          Replace Field Contents can be used manually or in a script to put a value into every record of your found set. So you can use Show All Records to modify the field in every record in your table or you can use a find to pull up a set of records, then use Replace Field Contents to assign a value to a field of every record in that found set.

          And you might want to set up Month as a date field, put 9/1/2014 into it as the month of September, 2014 and use data formatting to have it only display the month name. This gives you a value that you can sort into correct order if you need to sort your data by month, year.

          • 2. Re: How to insert data into a records set
            LanceMendoza

            Can you show me on how to do it in script. if i have 100+ entries how could i place it in month field using script to enter the month name automatically when i press a button that would trigger the script. I have a fix employee table, in that table there is a month field which to be filled up monthly. 

            August

            Month                      | Name                                    | Total Points
             August                    |  Juan Dela Cruz                    | 430 
             August                    | Nerissa Bascos                     | 420
             August                    | Noel Pagot                            | 445

             

            September

            Month                              | Name                                    | Total Points
             September                     |  Juan Dela Cruz                    | 430 
             September                     | Nerissa Bascos                     | 420
             September                     | Noel Pagot                            | 445

             

            Thank you very much for your help. 
            Please see attachment.

            • 3. Re: How to insert data into a records set
              philmodjunk

              And why is it necessary to put this value into so many records? (Perhaps there's a better design that won't require this.)

              The script, run from the layout shown, might look like this: (And I am assuming that the portal is NOT filtered.)

              If [ Not IsEmpty( Workers::EmployeeName ) //Make sure that there are related records to update ]  
                      Set Variable [$MonthName ; Value:LayoutTable::Month]
                      Go To Related Record [Show only related records; From table: Workers; Using layout: "Workers" (Workers) ]
                      Replace Field Contents [no dialog; Workers::Month; $Month]
                      Go to Layout [original layout]
              End If

               

              • 4. Re: How to insert data into a records set
                LanceMendoza
                 Thank you very much for your reply sir. Yes, your right if when i try to run the scenario i realize that theres something wrong with my design. If i did follow that and the workers record set have filled up by month i wont have any space left for next month. So i create another table that would solve my problem. The new table is the MonthlyPoints which will collect the data from month table and workers table. I also created a button (if Possible) that will import the month,year in month table and EmployeeName, AccumulatedPoints in workers table to MonthlyPoints. The MonthlyPoints table will keep all the employee data including month year in one row. The problem is there any way to put the month and year in workers table by auto entering month and year field. If i have 50 employeename, month and year should also be the same coz its filling every row. Can you help me on that script. I really appreciate your help. thank you very much.
                • 5. Re: How to insert data into a records set
                  philmodjunk

                  To Repeat an earlier recommendation: I don't think that you should link the records by a text field with the month name and a number field with the year. Better to link them by a single date field where you enter the specified month and year with 1 specified as the day. (BTW, you show month and year as two date fields and that won't work to hold the data you specify for those fields.)

                  In addition, this new table does not need an employee name field and this field should be removed. Since it's linked to your Workers table, the employee name in the workers table is all you need and keeping a second copy of the name in another table--especially one where you will have many records for the same employee, will greatly complicate things when an employee changes their name.

                  I really don't have a clear idea what you are attempting to accomplish here. What I can infer at this point is the existence of two tables that should be linked in this relationship:

                  Workers-----<MonthlyPoints

                  Workes::__pkEmployeeID = MonthlyPoints::_fkEmployeeID (I've renamed two fields you should already have for purposes of clarity)

                  For an explanation of the notation that I am using, see the first post of: Common Forum Relationship and Field Notations Explained

                  It would appear that you want to create a set of new records, one fore each employee for a specified month and year. This seems unnecessary as you can set up your database such that each time you enter the points data for a given employee, that data entry action can also create the related record. That approach would be much simpler than running a script to create all of these records once a month.

                  • 6. Re: How to insert data into a records set
                    LanceMendoza

                    Thank you very much for you quick response.. Please see images below. I really appreciate the way you help me. Hope you understand what i want to create by looking at the sample below.

                    • 7. Re: How to insert data into a records set
                      philmodjunk

                      What you show here is consistent with what I understood when I posted my last comments.

                      • 8. Re: How to insert data into a records set
                        LanceMendoza

                        Thank you very much.. I have a second question what if the monthly income is fix then i only need to change the month. I have a dropdown Field if i set it to September then click the button how could i fill the monthly income table with month employeename and monthlycome. See images below for reference. Im starting to understand how filemaker works but i still need your guide. 

                        • 9. Re: How to insert data into a records set
                          LanceMendoza

                          Sorry in the monthly income table filter by month. I forgot to change the accumulated points to MonthlyIncome

                          • 10. Re: How to insert data into a records set
                            philmodjunk

                            I can't tell from you posts exactly what you currently have set up. But if the income is the same every month, that would be a value to store in the Employee table.

                            • 11. Re: How to insert data into a records set
                              LanceMendoza

                              No value would be enter in the employee table unless there is a new employee or new monthly income adjustment. The month table is necessary to track any changes in employees data. Sorry for the late reply . 

                              • 12. Re: How to insert data into a records set
                                LanceMendoza

                                Hello Good Evening everybody.. Still there phil?