Reputation: 1595
I'm writing a script that's intended to work for multiple layouts and table occurrences. For each, it will determine the primary key and then find the maximum value in any record for that primary key field. That's all working well. Now, I've computed my intended next serial value and would like to assign this to a field whose name I have saved in a variable. I am unable to specify the target field by using a variable. I only see an option for selecting the table and field from a list of existing fields.
Is there a way to dynamically specify the target field?
Why is there a checkbox for "specify target field"? I see that I receive error 102 (missing field) when I do not specify a target field. I don't understand why it's optional but returns an error if it is not used. Why not make it mandatory?
As you might notice, I'm relatively new here, so I would also appreciate any tips about how I can improve the formatting or content of this question.
Upvotes: 0
Views: 1125
Reputation: 4892
Before we had Set Next Serial Value
, we used Replace Field Contents
to get the same effect, but it's more complicated, although it will allow you to do it dynamically. The basic idea is that you'll need to be on the record that has the maximum serial number, isolate that record, make sure you're on a layout with the serial number field, go to that field, and use Replace Field Contents
to set the field to itself while also updating the next serial value. The script would look something like this:
Go to Layout [ // layout that has the target field ]
Enter Find Mode
Set Field By Name [ $_target_field ; $_max_serial ]
Perform Find
Loop
Go to Next Field
Exit Loop If [ Get(ActiveFieldTableName) & "::" & Get(ActiveFieldName) = $_target_field ]
End Loop
Replace Field Contents [ No Dialog ; Replace with serial numbers: Custom values ; Initial Value: $_max_serial ; Increment by: 1 ; Update serial number in Entry Options ]
No, I haven't tested this out on a sample file, but it's the basic technique we used before FileMaker, Inc. gave us Set Next Serial Value
.
Upvotes: 1