1 2 Previous Next 17 Replies Latest reply on Jan 29, 2014 8:47 AM by disabled_dconnect

    Copy contents of 1 field in portal to main table field

      Title

      Copy contents of 1 field in portal to main table field

      Post

           Hi, I think this can be done after reading this

           How to copy data to one field from multiple portal records
           http://help.filemaker.com/app/answers/detail/a_id/2403/kw/copy%20field%20script

           However, I just want to dumb it down and copy the contents of 1 field of 1 record in my portal to 1 field of one record in the main table.

           How do I do this?

           NB:

           I have related 2 tables.

           1 table (main table) shows the portal of records from the other table (related table)

           I have a field in both tables with about 20 checkboxes to check.

           Quite often, I want them to show the same data, however, the data is only in the related table, and it takes a lot of time to check each of the boxes each time for each record, so I thought can I use a script, or something, to just copy the contents of the field in the record of related table, to main tables field.

           This would save a lot of time, if someone knows of a solution.

           Thanks :)

            

            

            

            

            

        • 1. Re: Copy contents of 1 field in portal to main table field
          philmodjunk

               A button in the portal row can do this:

               Set Field [ MainTable::CheckBoxField ; RelatedTable::CheckBoxField ]

               The mouse click on the button both performs the script and puts the focus on a specific portal row which then sets up the set field to transfer data from the selected related record.

          • 2. Re: Copy contents of 1 field in portal to main table field

                 Thanks Phil, this is a bit of a biggie so the help is much appreciated.

                 Not getting it to work.

                 I opened up button set up on the portal row.

                 I went to Fields, Set Field, and it asked me for "Specify target field" or calculated result.

                 I put different combinations of Set Field [ MainTable::CheckBoxField ; RelatedTable::CheckBoxField ] into the calculated result box, but it said missing this or that, for example: just putting MainTable::CheckBoxField ; RelatedTable::CheckBoxField into the box that pops up when you click calculated result asks for an operator ...

                 And just putting in RelatedTable::CheckBoxField, doesn't do anything when I click on the button. Also I couldn't find Set Field in the pop boxes all functions by name box.

                 The button is on the portal row as when I exit edit view there are buttons on each of the portal rows.

                 I remember what you said about right of the semi colon but that's not working either.

                 What's going wrong?

            • 3. Re: Copy contents of 1 field in portal to main table field

                   Hi Phil,

                   Just realised it was a run a script button.

                   All working :)))

              • 4. Re: Copy contents of 1 field in portal to main table field
                philmodjunk

                     Set Field is the first script in the Fields category of steps.

                     First, review what you are doing to set this up:

                     When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.

                     Check the result in the script editor. It should look exactly like what I typed except for the table/field names. If you see extra square brackets, you don't have it set up correctly.

                • 5. Re: Copy contents of 1 field in portal to main table field

                       Thanks Phil, this is a real time saver!!! :)))

                  • 6. Re: Copy contents of 1 field in portal to main table field

                         Hi Phil,

                         This is working perfectly to replace the field with the contents of another field.

                         Is there a way to just add the field to the top or bottom of the target field, rather than replacing the target field?

                         My idea is just add to the field, not to replace it.

                         Thanks

                    • 7. Re: Copy contents of 1 field in portal to main table field
                      philmodjunk

                           If you have just a single value in the portal field and you want to show an additional check box selected by adding this single value:

                           Set Field [ MainTable::CheckBoxField ; //see calc shown below ]

                           If ( IsEmpty ( FilterValues ( MainTable::CheckBoxField ; RelatedTable::CheckBoxField ) );
                                List ( MainTable::CheckBoxField ; RelatedTable::CheckBoxField ) ; 
                                MainTable::CheckBoxField
                               )

                           If there might be multiple items in the portal's field, the process of keeping the same value from being added more than once to the list in the MainTable field complicates the process.

                           Set Field [ MainTable::CheckBoxField ; List ( MainTable::CheckBoxField ; RelatedTable::CheckBoxField ) ]
                           Set Field [ MainTable::CheckBoxField ; ValueListItems ( Get ( FileName ) ; "UniqueValuesThisRecord" ) ]

                           This second line removes the duplicates, but it requires a self join relationship by primary key in order to set up a conditional value list of all values selected in MainTable::CheckBoxField for just the current record. If this is needed (duplicate values in a check box formatted field screw up the ability to remove a value by clearing a selected check box) and you don't know how to set up the "UniqueValuesThisRecord" value list, let me know.

                      • 8. Re: Copy contents of 1 field in portal to main table field

                             Thanks Phil,

                             All that works, very easy to set up too with your clear instructions :)

                             Just one question on it though.

                             Is there a way to add all RelatedTable::CheckBoxFields in the portal in one go?

                             (The portal shows anything from 5 to 100 records depending on how many records are filtered.)

                             For example:

                             When the portal shows 20 records can use the above script to copy all of the fields across into MainTable::CheckBoxField in one go.

                             With the help above I can set a button up on each row, but I'm guessing there is a way to do it in one go?

                             The only thing I think may be an issue is I cannot predict on each MainTable record how many records will be in the portal.

                        • 9. Re: Copy contents of 1 field in portal to main table field

                               Also,

                               Would it be possible with the script ...

                               Set Field [ MainTable::CheckBoxField ; //see calc shown below ]

                               If ( IsEmpty ( FilterValues ( MainTable::CheckBoxField ; RelatedTable::CheckBoxField ) );
                                    List ( MainTable::CheckBoxField ; RelatedTable::CheckBoxField ) ; 
                                    MainTable::CheckBoxField
                                   )

                               ... to use this on edit box field input and instead of having each new value on the next line under the last, to have it in the same line separated by a comma.

                               Thanks

                                

                          • 10. Re: Copy contents of 1 field in portal to main table field
                            philmodjunk

                                 What exactly should the field in the main table show?

                                 One value for each value that is selected at least once in the portal? This would be achieved most easily with a calculation field that uses ExecuteSQL with the DISTINCT keyword to drop out any duplicate values. The same function can be used to specify a comma as the "record separator" to produce you comma separated list. Or you can specify a return as that separator and format the result as a check box field.

                                 And no script is needed to produce this result as it all becomes a calculation.

                            • 11. Re: Copy contents of 1 field in portal to main table field

                                   Hi Phil,

                                   I've portal with three fields, date, company name, staff member.

                                   I've a button that adds all these fields into another field (thanks to you :)

                                   I want them to go into the field like this: date, company name, staff member

                                   not on top of each other:

                                   date

                                   company name

                                   staff member

                                   This is so I can read it easily on a one line edit box field.

                              • 12. Re: Copy contents of 1 field in portal to main table field
                                philmodjunk

                                     That reads like three different fields in the same record rather than values from different portals. That leaves me a bit puzzled as to how you have this set up.

                                • 13. Re: Copy contents of 1 field in portal to main table field

                                       Yes, it's three different fields in one portal record to be all entered into one field in the main table.

                                       Don't ask how I set things up!!! I'll probably frighten you with all my workarounds ;)!

                                  • 14. Re: Copy contents of 1 field in portal to main table field
                                    philmodjunk

                                         Sorry but I have to in order to suggest a solution. You originally described a check box field in a portal row and these latest posts don't appear to be describing a field of check boxes. Unless you are now discussing this in one of your newer threads, I suggest describing the task that you are trying to facilitate with your database here.

                                    1 2 Previous Next