Error messages on import via Javascript

Tap Forms – Organizer Database App for Mac, iPhone, and iPad Forums Script Talk Error messages on import via Javascript

Viewing 4 reply threads
  • Author
  • December 6, 2021 at 5:00 AM #45963

    Victor Warner


    1. I am importing several csv files into different forms via a form script

    2. Sam and Brendan have provided the code to achieve what is needed (see and )

    3. The form script exists in a form named “Client Contact Details”). Several forms are linked to to this (via Link to Form). (Client Contacts Details linked to forms :”Passport”, “Other ID” and “Notarial Act”.)

    4.The script to import adds separate code to import each csv file as mentioned in Sam’s post (

    >” The easiest way would be to copy the function and replace the mappings. So instead of Import_Entries() and Import_Whom() and you just change the file name, remap the field mapping and instead of form.addNewRecord() you do document.getFormNamed(“Other Form”).addNewRecord(). That means a bunch of duplicated code but it will work.”

    5. Now I am adding the code to import into a further form (“Notarised Documents”) which is not linked to the Client Contacts Folder. The script works properly – the data is imported without issue but generates a number of errors in the console log.

    The code:

    // this imports the Papa Parse script
    // replace with your field ID's
    let dup_field = "X";
    // Notarised documents
    var type_of_document_id = 'fld-d97eadb774254768bc874a8d9c39bb55';
    var country_id = 'fld-04fc73a0c470486aa95dde105f8c3bd7';
    var date_of_event_id = 'fld-01e1904f176e4f5589e4acb2935b77d9';
    var place_of_event_id = 'fld-44e431c6ad5744378dc396d30736d0b0';
    var date_notarised_id = 'fld-369e7b99cd0748f6a15a04cf500ba23f';
    var place_notarial_certificate_signed_id = 'fld-8aa2fb1ba19e48afab5f77bb9bca0742';
    var number_of_pages_id = 'fld-b6882198382f4b368dccfa874e69a563';
    var for_duplication_id = 'fld-03f0a59ce814421ba5107faa956c16c6';
    let dup_notarised_document = for_duplication_id;
    // Function to split date and ressemble (to be called later)
    function parseDate(dateString) {
    	if (!dateString) {
    		return undefined;
    	let pieces = dateString.split("/");
    	return new Date(pieces[2], pieces[1] - 1, pieces[0]);
    // Import notarial act
    function Import_NotarisedDocuments() {
    let filename = "file:///Users/victor/Library/Mobile Documents/com~apple~CloudDocs/filedtoday/personal/Tap forms import test/notariseddocuments.csv";
    	let csvFile = Utils.getTextFromUrl(filename);
    	if (!csvFile) {
    		console.log("No CSV file?");
    	var output = Papa.parse(csvFile);
    	// abort if there are any errors and log to console.
    	if (output.errors.length > 0) {
    	// read each line
    	for (let line of {
    		// date of event parsing
    		let date_of_event_id_string = line[2];
    		let date_of_event = parseDate(date_of_event_id_string);
    		// date certificate signed parsing
    		let date_notarised_id_string = line[4];
    		let notarised_date = parseDate(date_notarised_id_string);
    		var newRecord = document.getFormNamed("Notarised documents").addNewRecord();
    			[type_of_document_id]: line[0],
    			[country_id]: line[1],
    			[date_of_event_id]: date_of_event,
    			[place_of_event_id]: line[3],
    			[date_notarised_id]: notarised_date,
    			[place_notarial_certificate_signed_id]: line[5],
    			[number_of_pages_id]: line[6],
    			[dup_notarised_document]: dup_field,

    (This is the stand alone version – but the issue is the same whether combined with the code to import for the other form or as standalone).

    The errors which are generated are:

    How provided wording: TypeError: undefined is not an object (evaluating 'client_name.toUpperCase'), line:(null)

    Query: Is this an issue which I should not worry about. Or is there anything I need to add so that the errors do not appear?

    December 6, 2021 at 5:29 PM #45968

    Sam Moffatt

    Are you sure that error isn’t generated by a field script? I don’t see anything that would cause that error in the script you pasted but it’s possible the messages actually come from a field script that is executing when the values are updated.

    December 7, 2021 at 12:58 AM #45969

    Sam Moffatt

    As an aside if it is in a field script, you might be ok with it erroring out like you see there but you can also likely detect when it’s empty and replace it with an empty string:

    if (!client_name) {
        client_name = "";

    That should fix the toUpperCase error from occurring. The undefined could be other log messages that are occurring similarly with stamp. The down side of console.log is that it all gets thrown in together.

    December 7, 2021 at 1:15 AM #45970


    I suppose a Console Log window that splits the output from the console log would be useful, like on the script editor.

    December 7, 2021 at 6:07 PM #45981

    Sam Moffatt

    I could see a debug mode option to prefix the lines with the script that the log message was coming from, I struggle with that with errors from time to time figuring out which library actually choked. I’m not entirely sure that’s actually possible due to how I understand the JSC integration works because it’s not obvious the context you’re calling from includes the layers of parser or not.

Viewing 4 reply threads

You must be logged in to reply to this topic.