AnsweredAssumed Answered

Replace Field Contents can set repetition 0 in multiple field

Question asked by Federico on Mar 23, 2012
Latest reply on Mar 27, 2012 by TSGal

Summary

Replace Field Contents can set repetition 0 in multiple field

Product

FileMaker Pro

Version

11.0v4

Operating system version

Mac OS X 10.7.3

Description of the issue

With script function "Replace Field Contents" is possible to insert a value in the repeat 0 of a multiple field.

Steps to reproduce the problem

Create a multiple field, let's call it MultipleField, type Number, with n repeats (where n>1 obviously).
Create a calculation field, result type Number, defined as Sum ( MultipleField ).
Create a layout to display the fields above.
Create a script with the following instruction:
Replace Field Contents [ MultipleField[0] ; 3 ]
to replace repeat 0 of MultipleField with any value you like (in this example, number 3).
Create some records, if you like put some values in MultipleField.
Run the script, then check the result of the sum field: you'll see that the calculation field gives a number that is the sum of all repeats of MultipleField, included the value replaced at index 0 with the script.

Expected result

Supposing that a multiple field is instantiated as an array, the index 0 of that array in FileMaker can't be read nor written by any function, except Replace Field Contents. So, I expect that also this function can't write in that location.

Actual result

The position 0 of the array can be written by Replace Field Contents.
This may be counterproductive. For example, suppose to have a script that substitutes the values in a repetition of a multiple field, with the number of repetition determined by a variable. If, for any reason, the value of that variable is 0, many problems may arise.

Workaround

The only workaround is to check the value of the repetition set in the Replace Field Contents instruction. Just be careful to enter only values greater than 0 and, especially, check variables values before using them to determine the repeat.

Outcomes