One form stating that scripts cannot find 'result' variable

Tap Forms – Organizer Database App for Mac, iPhone, and iPad Forums Using Tap Forms One form stating that scripts cannot find 'result' variable

Viewing 2 reply threads
  • Author
    Posts
  • April 4, 2019 at 5:08 AM #34279

    Victor Warner
    Participant

    One form in the Script editor is now indicating that when I click on the ‘Run Script’ button that
    it cannot find the variable ‘result’ = “ReferenceError: Can’t find variable: result, column:7, line:17”

    For a new field which contains the script no value is shown in the field (ie it is blank)

    With the same script in another field which was entered previously entered, that field still shows the data (although in Script editor, when clicking on the ‘Run Script’ button, I also get the same error).

    This error is affecting all of the fields containing a script, but not other forms.

    One of the scripts is:

    var directors_id = 'fld-b97b1fadf82f42e08b2f8be84b5a0bb9';
    
    director_name_record = record.getFieldValue(directors_id)
    
    if (director_name_record.length >0) {
    
    var first_director_name_record = director_name_record[0]
    
    var client_name_individual_upper_case_id = 'fld-7601d096dbd445aaa498645e199ecd29';
    
    var UpperCaseName = first_director_name_record.getFieldValue(client_name_individual_upper_case_id)
    
    result = UpperCaseName
    
    }
    
    result;

    Why might this be the case?

    April 4, 2019 at 6:46 AM #34280

    Victor Warner
    Participant

    I think I have solved the problem:

    I added near the top of the script:

    result = '':`

    and the error message disappeared and the script runs properly.

    April 4, 2019 at 11:03 AM #34282

    Brendan
    Keymaster

    That makes sense because of the scope of the result. Since your first occurrence of result is within the if statement, it is not valid outside of the if statement. Declaring it outside of the if statement allows it to be available to be returned.

Viewing 2 reply threads

You must be logged in to reply to this topic.