PowerShell Script Action, how to get data from a script?

Jul 21, 2011 at 1:15 PM

Hello, tell me, can I get data from the script executable with "PowerShell Script Action"?

I can transmit data to a script using the var1-var5. But if, for assigning a variable in the script $ var1 = "Hello word", then the variable workflow process mapped to var1, does not change.

Nov 15, 2011 at 2:51 PM

Same problem here.

In the documentation for the PowerShell Script Action (http://ilovesharepoint.codeplex.com/wikipage?title=Execute%20PowerShell%20Script%20Action&referringTitle=Workflow%20Actions%20for%20SharePoint%20Designer%202010) is written that the binding is two way, so it should work. But the var1-var5 don't get written back to the associated worklow variables.

Nov 15, 2011 at 3:39 PM

Okay, got it to work.

You have to consider two things:

  1. Use the global context of the variable:
    $global:var1 = "value"  
  2. If all you need is a string you are okay, if not, convert the value to a string.
    Here you have to be very carefully, because if you then assign the worflow variable again to a float or datetime, than the variable has to be in a culture specific format.
    $value = 0.33
    $culture = [System.Globalization.CultureInfo]::CurrentCulture
    $global:var = $value.ToString($culture) #0,33 if you live in a country with a decimal comma