Is there a way to pass variables to tasks from the script? Maybe I'm going about this the wrong way. I would like to load test a webapp that needs unique data per transaction. Is this the best way to handle this?
You might want to read the help topics about "Modifying recorded traffic". This is probably the best way about doing what you want to do.
One caveat is that you will be executing some code for each modified request going out. The more code executed, the more delay between requests. This might skew performance metrics. To this end, I usually end up not doing much at all in the way of traffic modification but making sure that I design my recorded tasks to be relatively generic while still exercising the site.