how many fields from how many records are we talking about?
Todd Geist, in one of his DevCon sessions this year, suggested that scripted Set Field commands can be used. This technique has a couple of really important advantages over Import (among others):
1) You can perform individual error trapping on each target record (which Import can't).
2) You can revert record changes on a particular record if you get a validation error.
The trick lies in the fact that the first Set Field command opens the record; subsequent Set Field commands will act on the opened record and thus a Revert will back out all the changes.
I need to do this in a few different places, but generally, there area about 8 fields and anything from 1 to 10 records.
You can loop through the source recrods, collect the data in repeating variables then turn around to the target TO and create new records based on the contents of the variables. If you do not have to collect related info from any of the source records then you can use the getNthRecord function and avoid phyically looping through the records. That kind of approach is very fast for small(ish) sets of data.
That's what I was going to do, then discovered a problem with getrepetition on variables, it does not seem to work in v12! So I am using a global field - actually I am grabbing I'd fields and via 1-1 relationship I'm using insert calculated result to populate fields, which suits this situation well
What doesn't work? I do this extensively and haven't run into any issues. Can you expand on what you're finding and maybe post a bit of code?
I was using a variable in a loop, setting each repetition of the variable with a value.
This worked a treat, it shows the correct values in data viewer but when using getrepetition, it did not return a repetition (beyond the first) I have read on fmexperts that this is problematic, despite the fact that I have used this technique in older versions of fm?
GetRepetition only works on repeating fields, not repeating variables.
To extract a certain repeittion of a variable you would use $myvariable[ someRep ]
When you set a variable you specify the rep # in the bottom input field of the Set Variable scrpt step. To use it in a calc window you use the square brackets syntax that I mention above.
I'm sure it USED TO work... but that's ok, I know I can extract the values from the variable, but I also figured it might be safer to use a field, being used on FMGo, I'd rather not push the boundaries of the "RAM", the field can be populated and cleared at the end... it "feels" safer.
I'm sure it STILL works in FMP12.
I use it in my solutions and I know it works. I set the repetition of the variable to the Current Layout Number. This allows me to store layout specific information in the variable, like the currently selected field or object. When returning to that layout I can also return to the selected object, field, or even a specific record, etc.
$layout_var[Get ( LayoutNumber )]
Returns the value of the variable "$layout_var" for that layout number (repetition).