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?
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.
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.