Script error with variable being treated as a function

Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch Forums Script Talk Script error with variable being treated as a function

Viewing 1 reply thread
  • Author
    Posts
  • August 8, 2025 at 4:36 PM #52839

    Victor Warner
    Participant

    I have a field script in Form which pulls in data from another Form (client_contact_details), which was working the last time I used it, but it is now producing an error:

    Email adress for invoice: TypeError: client_first_name_and_email_address_details.getFieldValue is not a function. (In 'client_first_name_and_email_address_details.getFieldValue(company_name_id)', 'client_first_name_and_email_address_details.getFieldValue' is undefined),line:(null)

    The script is now within a function, so I do not understand the error means. Any help in solving this would be greatly appreciated.

    The script:

    // Return values
    var Dear_Name = "Placeholder";
    var Email_to_send_invoice = "test@example.com";
    
    // Form ID
    var client_contact_details_id = 'fld-c53e48e48e3a40c7a5656ab92f39ecc9';
    var client_first_name_and_email_address_details = record.getFieldValue(client_contact_details_id)
    
    //Company details
    // company name
    var company_name_id = 'fld-a3300e3db044421598ae171c0a2d4834';
    var company_name = client_first_name_and_email_address_details.getFieldValue(company_name_id);
    
    console.log(company_name);
    
    if (company_name == null) {
    // first name of individual
        var first_name_id = 'fld-45599a4f0a6342d8973faed53dfbfed8';
        var first_name = client_first_name_and_email_address_details.getFieldValue(first_name_id);
    
        // Email address of individual
        var email_id = 'fld-8f9a928a7d554527b4127ef811136210';
        var email_individual = client_first_name_and_email_address_details.getFieldValue(email_id);
    
        Dear_Name = first_name;
        Email_to_send_invoice = email_individual;
    } else {
        // first name of company contact
        var first_name_company_contact_id = 'fld-24ee4dae33d941bf81e1667853a7a949';
        var first_name_company_contact = client_first_name_and_email_address_details.getFieldValue(first_name_company_contact_id);
    
        // email address of company contact
        var email_company_contact_id = 'fld-8cfa7613f04f4a8b82652bc27f3c05df';
        var email_company = client_first_name_and_email_address_details.getFieldValue(email_company_contact_id);
    
        Dear_Name = first_name_company_contact;
        Email_to_send_invoice = email_company;
    }
    
    console.log(Dear_Name + " " + Email_to_send_invoice);
    
    Email_to_send_invoice;
    August 8, 2025 at 7:02 PM #52840

    Daniel Leu
    Participant

    Two things come to my mind:

    1. 1) Is client_first_name_and_email_address_details defined? Maybe the contact details link is missing. In this case I would use if (client_first_name_and_email_address_details == undefined) return; to skip the rest of your script. You might want to add a log message as well.
    2. 2) Did you just migrate to Tap Forms Pro? If yes, client_first_name_and_email_address_details is likely an array. So you might want to use just the first element with client_first_name_and_email_address_details[0].
    • This reply was modified 5 days, 17 hours ago by Daniel Leu.

    Cheers, Daniel
    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

Viewing 1 reply thread

You must be logged in to reply to this topic.