How to import “linked” forms

Tagged: 

Viewing 4 reply threads
  • Author
    Posts
  • August 2, 2021 at 2:31 PM #44894

    Aaron Greenhouse
    Participant

    I’ve been trying to import previously exported records that use “link to form” fields. I have not been able to get this to work. Specifically, I’ve been creating simple test forms, a Parent and a Child form. The Parent form has a text field for a name, and a link to from field that refers to Child forms. The Child form just has a text field for a name. I create a few parents forms and child forms and link them together. I export the parent records and select “export linked records”. The export seems to work just fine. I get two .csv files, one for the parent forms and one for the referenced Child forms.

    Import is a problem though. The only guidance given in the manual is to import the parent forms first, and then the child forms. I can import the parent forms no problem. But when import the child forms, one of two things happens

    1. I get the child forms, but the parent forms do not link to them, or
    2. I don’t get any child forms.

    I’ve tried this with and without exporting the record ids. Doesn’t make a difference, but it seems like I probably should export the record ids.

    What am I doing wrong?

    I was playing with this because I have a more specific problem I want to solve. I was a bad boy and I was using a spreadsheet as a database. (I know, boo hiss.). So now I’m using TapForms, but I need to import my old spreadsheet. This is of course straightforward if I treat it is a giant .csv file. The problem is, the order of items in the spreadsheet matters. Basically, each row is a purchased item, and adjacent items are part of the same overall purchase. (This can all be differentiated by data column and a vendor column.). I would like to instead have a Purchase form, and an item form, and have the purchase link to the items. I’ve created a new TapForms database taht does this and it works just fine for my new purchases, but I need to import my old.

    I don’t know what is the best way to do this. I was thinking the best thing to do would be to create a new .csv file for the old purchases. This would have to do be done by hand by me. I would have to link these to the old items. Now, I know I can just create unique ids for each purchase, and add them to the items, and then use the JOIN link type to make this work, but that forces me to use JOIN for the new records as well, and I don’t want to do that. So I was trying to figure out how to emulate the what is done by the import function. But since I cannot get the import function to work at all, I’m at a loss of what to do.

    I’m open to other ideas about how to solve this problem, if anyone has one.

    THanks.

    August 4, 2021 at 9:33 AM #44908

    Brendan
    Keymaster

    What is your reservation about using the Join Link Type?

    Were you importing your CSV files into the same document from whence they came? If so, then the unique record IDs would simply be matched with existing records and those records updated. You wouldn’t get new records for them.

    August 4, 2021 at 9:38 AM #44910

    Aaron Greenhouse
    Participant

    With regards to the import problem, I was importing into a new empty document.

    The problem I have with the Join Link type is that I created a new database for purchases and items after date X, and in that database I have used the 1 to many link type and set the links explicitly. I would like to import my old data from the spreadsheet (from before date X) into the new database. I cannot have both JOIN and 1-to-Many for the same field. I suppose I could have two fields, “Purchase” and “Legacy Purchase.” I could live with that. Is there a way, perhaps using a script, to copy the references from a “JOIN link” field to a 1-to-Many field?

    August 4, 2021 at 4:15 PM #44915

    Sam Moffatt
    Participant

    You can use a script to get the children of one Link to Form field of JOIN type and then add them to another Link to Form field. In terms of script, a form script like this should do the trick:

    record.getFieldValue('fld-joinfieldid').forEach(rec => record.addRecordToField(rec, 'fld-1tomanyfieldid'));
    

    You could expand it to run on all of the records in your form but this will do just the currently selected record. I haven’t tested it but it should work.

    August 4, 2021 at 5:01 PM #44916

    Aaron Greenhouse
    Participant

    Thanks! That should be enough to get me on my way!

Viewing 4 reply threads

You must be logged in to reply to this topic.