Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Using Tap Forms › TFARC export-import question
Tagged: tfarc import export linked forms
- This topic has 7 replies, 2 voices, and was last updated 7 years, 4 months ago by Mike Schwartz.
-
AuthorPosts
-
August 20, 2017 at 10:36 AM #24085
Mike SchwartzParticipantBrendan,
I have two related forms, “Departments” and “Organization”, that I decided to move to a new Tap Forms document file. The Departments parent form has a few link fields that link to the Organization child form.
I exported both of the forms to my desktop as Tap Forms Archives. Then I created a new database document and figured that I would need to import both of the tfarc files. But after importing the first archive file for Departments, I was surprised to see that my document immediately contained both the Departments form AND the Organization form, which I hadn’t yet imported. Magic!
Can you explain a little more about how tfarc import behaves? It looks as if Tap Forms will bring along a child form when you import a parent form. Where did the Organization child form come from? Was it from the exported tfarc file on my desktop, or was it from the source Tap Forms document where the original form resides? Would it have worked the same way if my source Tap Forms document had been closed at the time of import? I did a separate test by first importing the child Organization archive file into a clean document — the parent Departments form did not magically appear along with it.
Thanks for any insight you can provide.
— Mike
August 20, 2017 at 2:45 PM #24088
BrendanKeymasterHi Mike,
Yes, when you export a Tap Forms Archive from a parent form, Tap Forms will traverse through the forms and export the records from the child forms too. The single .tfarc file will contain the parent form and all linked fields and their data. It’s a recursive algorithm.
It goes top-down, not bottom-up, so that’s why importing the Organization .tfarc file didn’t also import the Departments .tfarc file data. But importing the Departments .tfarc file will import the related Organization form and records.
You only need to export the top-most parent form as a .tfarc file.
August 20, 2017 at 3:13 PM #24091
Mike SchwartzParticipantThank you, this is good to know.
Just to tug on this thread a little more, will the Departments tfarc file pull in ALL the records of the child Organization form, or only those records that appear in the Link to Form fields throughout the Departments file?
If it’s the latter, then I might be missing some data from the Organization form that I’ll need later on. If that’s the case, what would happen if I try to import the separate Organization tfarc file after I have already imported the Departments file that included data from the Organization file. Would it fill in the missing records from the Organization file, or create a second form with the same name but more records? That might get messy.
Thanks,
MikeAugust 21, 2017 at 4:08 PM #24115
BrendanKeymasterHi Mike,
It should export both the records for the form that’s linked, but also the links themselves. Not just the records only that are linked. I just had to check my code again to make sure and it should do both because it loops through all the fields and then if any of the fields are Link to Form fields, it recursively calls the same method again to export the data, but with the new form that’s being linked to by the Link to Form field. So eventually it will export all of the records for all of the linked forms. Plus it will export all the links themselves. I store the links in a separate TFLinkRecord data structure.
August 21, 2017 at 6:11 PM #24116
Mike SchwartzParticipantBrendan,
Sorry for being dense about this, but I’m still not seeing the answer that I’m looking for. Let me try with a numerical example:
1. The parent form has 100 records, and the child form has 1000 records.
2. The parent form has one Link to Form field that links to the child.
3. For the parent form, 90 of the 100 records have entries in the Link to Form field.
4. Across those 90 parent records, 200 unique child records are linked.I export the parent form as a tfarc file, then import it to a new document. I understand that the new document will include (a) the parent form (all 100 records), (b) all the link data for the 90 parent records that had links, and (c) the child form with (at least) the 200 records that are linked to the parent.
QUESTION: Will the child form in the new document contain ONLY the 200 linked records, or all 1000 records from the original child file?
Thanks,
MikeAugust 21, 2017 at 7:20 PM #24118
BrendanKeymasterAnd to answer your question about re-importing the other .tfarc file, Tap Forms will update existing records and add new ones. It does this because the record Ids internal to the .tfarc file are the same as what you’ve already imported. And ones that aren’t found just naturally get added.
August 21, 2017 at 7:24 PM #24119
BrendanKeymasterIt should contain all 1000 records from the original child. I just tested this. I had a child form with 23 records. I added one directly to it so now there’s 24, one not linked to any other parent record. I then exported the parent form and there were 24 child records there in the child, just as there should be.
August 22, 2017 at 8:25 AM #24129
Mike SchwartzParticipantPerfect! Thanks a million for the code-dive and testing.
— Mike
-
AuthorPosts
You must be logged in to reply to this topic.