Linked records export error

Tagged: ,

Viewing 8 reply threads
  • Author
    Posts
  • January 21, 2025 at 11:45 AM #51544

    Calion
    Participant

    When I export a Form with a Table field, the resulting export puts the content of the next field into the Table field, and the contents of the Table field are just lost.

    January 21, 2025 at 4:51 PM #51548

    Calion
    Participant

    Is there a way to remedy this? Is this a bug?

    January 21, 2025 at 6:51 PM #51550

    Brendan
    Keymaster

    You should see multiple files created. One with the parent records and one with the contents of the Table field. I just tested that with my Invoices form and it’s working as expected.

    Do you have the latest version of Tap Forms 5.3.41?

    January 21, 2025 at 9:19 PM #51553

    Calion
    Participant

    Apologies; I didn’t mention that I’m on iPad. I’m using the latest version (5.3.37).

    I have “Export Linked Records” off.

    • This reply was modified 1 month ago by Calion.
    January 23, 2025 at 9:36 PM #51562

    Brendan
    Keymaster

    You should enable Export Linked Records for forms that have a Table field or a Link to Form field. Also enable record IDs export too.

    January 24, 2025 at 9:31 AM #51568

    Calion
    Participant

    Okay, turning on record IDs does help the situation, but what I’d greatly prefer is if, when Export Linked Records is off, the linked records all get shoved into one field.

    And there remains the bug that when Export Linked Records is off, data is put in the wrong fields, so you could kill two birds with one stone.

    January 25, 2025 at 3:26 PM #51571

    Daniel Leu
    Participant

    What you could do is using a field script that combines all table data into one field. Then when you export your form, such data would be included.

    Here’s an example of such a field script. You need to replace ‘fld-xxx’ with the field id of your table.

    function Table_Text() {
    
    	// set field value according to your form
    	const table_id = 'fld-xxx';
    
    	// get table records
    	let tableRecs = record.getFieldValue(table_id);
    	
    	// extract all table values
    	let tableValues = [];
    	tableRecs.forEach( (a) => {tableValues.push(a.values)});
    	
    	//console.log("Raw data:\n"+JSON.stringify(tableValues,"",4));
    	
    	// extract all table values
    	let tableText = [];
    	for (tableValue of tableValues){
    		let row = [];
    		for (const [key, value] of Object.entries(tableValue)) {
    			row.push(value);
    		}
    		tableText.push(row.reverse().join(", "));
    	}
    	
    	//console.log("Extracted data:\n"+tableText.join("\n"));
    	return tableText.join("\n");	
    }
    
    Table_Text();
    
    January 26, 2025 at 11:17 AM #51574

    Calion
    Participant

    How do I get the field ID?

    // Okay, I found the answer to that, but nothing is showing up in the script field.

    Here’s the script:

    function Table_Text() {
    
    	// set field value according to your form
    	const table_id = 'fld-26a15768a8f54cc5b8cc3cec0cd7d295';
    
    	// get table records
    	let tableRecs = record.getFieldValue(table_id);
    	
    	// extract all table values
    	let tableValues = [];
    	tableRecs.forEach( (a) => {tableValues.push(a.values)});
    	
    	//console.log("Raw data:\n"+JSON.stringify(tableValues,"",4));
    	
    	// extract all table values
    	let tableText = [];
    	for (tableValue of tableValues){
    		let row = [];
    		for (const [key, value] of Object.entries(tableValue)) {
    			row.push(value);
    		}
    		tableText.push(row.reverse().join(", "));
    	}
    	
    	//console.log("Extracted data:\n"+tableText.join("\n"));
    	return tableText.join("\n");	
    }
    
    Table_Text();

    I set the Result Type to text, but that didn’t change anything.

    • This reply was modified 3 weeks, 6 days ago by Calion.
    January 26, 2025 at 5:47 PM #51576

    Daniel Leu
    Participant

    When you run the script in the editor, what is the console output? Do you get anything?

    Attached is my test form showing that my script works.

    Attachments:
    You must be logged in to view attached files.
Viewing 8 reply threads

You must be logged in to reply to this topic.