The second parameter of AFSimple_Calculate needs to be a comma-separated
string containing the names of the fields you want to sum up.
The variable arr that you define in your code is not available in the
context of the action that you're setting, and anyway it's not the right
variable type. You should use a string, not at array of strings.
Also, I would avoid mixing single and double-quotes. It's a bit confusing.
Instead, use just double-quotes, but escape them when they are in a string.
A tip. Getting to grips with escaped strings can be tough, for example knowing that to get The "best" stuff in a string you have to write "The \"best\" stuff" and to get "The \"best\" stuff" in a string you have to write "\"The \\\"best\\\" stuff\"" .
To confirm your string contains what you think it does, simply display it in a message or the console.
thx for the info. I got the use of an array from this: http://www.verydoc.com/documents/acrojsguide/pg_0101.htm
The single quote around AFsimple_calculate seem to be mandatory though, can't replace them with ".
any idea how to succesfully create the string? it works great for a hardcoded string like 'AFsimple_calculate("SUM","3.sms,3.Data")' for example. But as soon as I add a variable it doesn't work...
Also when I check the console for errors and I select "Script and Console", the displayed script doesn't contain any adjustments. So I'm not even sure the script is succesfully reloaded or that the errors that are displayed apply to the current script.....
(make sure you use the correct spelling. JS is case-sensitive, so AFsimple_calculate is not going to work)
the problem isn't \". setAction("Calculate",'AFsimple_Calculate("SUM","3.sms,3.Data")'); is a correct syntax. What I want is to be able to insert a variable instead of the 3. So that for product 4, 4.Totaal will be created and that it will calculate the sum of 4.sms and 4.Data...
I tried creating a string first like:
arr = id+".sms,"+id+".Data";
but it just returns the "arr is not defined" error.
I'll create a test textfield and execute the code line by line in the console, see if the error is truely in the AFsimple_Calculate syntax...
setAction("Calculate", "AFSimple_Calculate(\"SUM\",\"" + id + ".sms," + id + ".Data\")")
thx! that did the trick
The setAction method can't be used in Reader.