Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Using Tap Forms › Table : Copy records from
- This topic has 3 replies, 2 voices, and was last updated 2 years, 2 months ago by Brendan.
-
AuthorPosts
-
September 1, 2022 at 2:53 AM #47883
John CranneyParticipantIn the table field properties, there is a dropdown called “Copy records from”.
Under this dropdown, it says “Tap Forms will copy values from the selected records based on matching field titles”.
What does this functionality actually do? From the description it looks like it can be used to populate a table with data (I want to use a table to show data from a linked form, as on iOS tables are the only way to view nested data without clicking through).
However I can’t get the feature to do anything for me.
Attachments:
You must be logged in to view attached files.September 1, 2022 at 10:46 PM #47890
BrendanKeymasterSo on your Table field there will be a checkmark button. Click on that and it will show the list of records from the “Copy records from” form you selected. When you select a record, the values from the fields in the selected records will be copied to the corresponding fields in the Table field record itself.
It’s similar to the Link to Form field except instead of referencing the linked records, it copies the values from them into new records in the Table field. This gives you the ability to do things like have a product form that contains a bunch of products, but when you select the products, you can enter in a different quantity and price for each of the selected products than what might otherwise be on the Product form itself. If you were linking to the Products form with a Link to Form field, whatever fields are on the Product form are what you get. But with a Table field you can have some common fields and some different fields.
Hope that makes sense.
Thanks,
Brendan
September 1, 2022 at 10:56 PM #47893
John CranneyParticipantIt does make sense, thanks.
I was trying to get it to work using a script and I think I found some odd behaviour.
Say I have a linked form (stuff_link_id) and a table that I want to display a view of records in that table (stuff_table_id). If I click the checkmark button as you mention above, I get a copy of the selected stuff_link record in my table, with values magically populated.
However if I run the following (which I was hoping would populate the table with a view of whatever is linked in link) it deletes the record from link and moves it to table. Is that intentional? I expected it would do the same magic population. I’ve got a workaround which is to use duplicate() but I need to manually set all the columns.
var records=form.getRecords();
for (var rec of records){
for (var stuff_rec of rec.getFieldValue(stuff_link_id)) {
rec.addRecordToField(stuff_rec,stuff_table_id);
}
}document.saveAllChanges();
September 5, 2022 at 12:02 AM #47902
BrendanKeymasterHi John,
Link to Form fields and Table fields do operate a little differently. Table field records contain within them a parent record property. There can be only one parent record per Table field record. So that means if you try to add a record to a Table field from a linked form, that record will be moved to the Table field’s list of records.
Thanks,
Brendan
-
AuthorPosts
You must be logged in to reply to this topic.