I’m trying to script a method that works similarly to the Replace Contents command in Filemaker - a user clicks in a field and then runs a method to replace all values in that field in the foundset with the value in the current record. The field element name is identified by populating a global field with the onFocusGained action (globals.fieldName). Then a method is run with the following code (from which I borrowed liberally from the sample):
if (globals.fieldName == null)
{
var thePressedButton = plugins.dialogs.showErrorDialog('Error', 'You must select a field to replace values','OK');
return;
}
var fieldID = elements[globals.fieldName].getDataProviderID();
var val = controller.getDataProviderValue(fieldID);
var msg = "Are you sure you want to replace the contents of [" + globals.fieldName + "]\nwith the value: '" + val + "' in all " + globals.recordMax + " records of the found set?";
var answer = plugins.dialogs.showQuestionDialog( "Replace Contents", msg, 'Cancel', 'OK');
if (answer == 'OK')
{
var fsUpdater = databaseManager.getFoundSetUpdater(foundset);
fsUpdater.setColumn(fieldID,val);
fsUpdater.performUpdate();
}
In the example I was testing, I have 17 records in the foundset. All works well with the script and the variables are populated correctly, but when the update occurs, based on the stack trace, only the current record is updated - the other records in the foundset are not touched.
What am I doing wrong? BTW, I’m running 2.2.1 rc3.