Adding variable to Script task dynamically
I have a string expression that I need to evaluate dynamically (string replace), and the tokens that need to be replaced reference package variables dynamically so there is no way to know which variable will be called into play. How can i add variables to the readonly collection of the script task dynamically from the script itself? Javier Guillen http://www.msbicentral.com/Blogs/JavierGuillen.aspx
January 18th, 2011 4:56pm

Is the script task being called from within a ForEach Loop? Perhaps I would store the variables in an Object variable that could be processed or even a file, table, etc. instead?Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
January 18th, 2011 5:28pm

No, it all runs within the script task itself.... So the script takes a string with tokens which need to be replaced dynamically with different package (and parent package) variables; So in theory this should all happen within the script itself, and there is no way to know which variables should be added to the read or read/write collection Can this collection be modified at runtime? Javier Guillen http://www.msbicentral.com/Blogs/JavierGuillen.aspx
January 18th, 2011 5:54pm

So it seems to me you need to declare a dynamic (not sized) array/list of object variables. But how do you invision using such a super flexible Script Task? I just cannot imagine its interface. Isn't it better to build a custom component?Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
January 18th, 2011 6:05pm

Then you'll need to lock and read the variables entirely within the script itself, and not use the ReadOnlyVariables or ReadWriteVariables collections. This is one of the few use cases where I'd say this is OK. You need to read a few blog posts: Reading and Writing to Variables in the Script Task - Arie Jones Writing to a variable from a script task - Jamie Thomson But please do be cautious about trying to do this every time, I don't recommend it. Talk to me now on
January 18th, 2011 6:44pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics