The reason i want to set the parameter in the script is to make a generic way to set parameters in one place, as the reason behind setting the parameters are:
1-read parameters earlier set for this report from my database.
2-set these parameters through script. As i already know the parameternames and values (from my database).
If i have to set them parameter by parameter in the parameter script, it would work, but wont be a good solution i think.
But isnt there a way to set the parameter values in the script, havent seen any post about it, been searching for an answer for some days now.
reportContext.setParameterValue("NewParameter", 2); Or using the code you posted should work.
The problem will be the parameter box will display the default value you designed in. If you hit ok on it the new value will then be set in the parameter box. You can hide the parameter box in a couple of ways, but I am not certain that is what you need.