AnsweredAssumed Answered

In a Let Statement in a calculation, a Field used in a condition for an If statement does not get...

Question asked by NigelBrowning on Apr 18, 2013
Latest reply on May 9, 2016 by TSGal

Summary

In a Let Statement in a calculation, a Field used in a condition for an If statement does not get its name updated if the field is renamed

Product

FileMaker Pro

Version

FileMaker Pro 12 Advanced 12.0v3

Operating system version

Mac OS X version 10.6.8

Description of the issue

In a calculated in a field, whether it be an AutoEnter or an ordinary calculated field, Field Names do not get updated it they are renamed, even in the same table, if it is being used within a Let Statement and as part of the condition of an If Statement.

Steps to reproduce the problem

In a new table of a new database, create:
1. A text field, named 'Source'
2. A calculated field, named 'Target'
3. Use the following as the calculation:

Let ( [
ret = If ( Source = 1 ; 1 )
] ;
ret
)

4. Now rename the field 'Source' as , e.g., 'SourceA'
5. The calculation will still work, but its text will not change and the Calculation Editing Dialog will throw a parsing error if an attempt is made to edit it without re-pointing it to the newly-renamed field.

Expected result

All references to fields are automatically renamed in calculations: thus the text representation of the calculation ought to appear as :

Let ( [
ret = If ( SourceA = 1 ; 1 )
] ;
ret
)

Actual result

Let ( [
ret = If ( Source = 1 ; 1 )
] ;
ret
)

Exact text of any error message(s) that appear

The specified field cannot be found

Workaround

If the value of the field is placed into a variable, that can be used in the condition of the If Statement, e.g.:

Let ( [
fld = Source ;
ret = If ( fld = 1 ; 1 )
] ;
ret
)

Alternatively, force FM to realise that the fieldname is a field by surrounding it with a function, e.g.:

Let ( [
ret = If ( GetAsNumber ( Source ) = 1 ; 1 )
] ;
ret
)

Outcomes