Great project idea...

Mar 6, 2011 at 7:07 PM

Hi Craig,

I've downloaded your initial uploaded code and had a play.  I found a few problems saving settings and the like and in the end created my own workflow.  I was aiming to reduce the number of parameters required to the workflow, after all, we can put the intelligence in our powershell :)

I've got the sequence so that it simply exposes the workflowdata (via runspace.SessionStateProxy.SetVariable) to the powershell environment.  So every workflow variable is available via a hashtable $workflowdata.
Then I lookup the request and available attributes, then expose the request as $request, plus all attributes as $target
Once the powershell has completed any changes to $workflowdata are carried through thanks to the SessionStateProxy, I also then compare the final output of $target against the original, if any changes then perform an update.

The workflow sequence is then: CurrentRequestActivity -> Helper Code -> readResourceActivity (Initial) -> Helper Code -> readResourceActivity (Full Attributes) -> Helper Code -> execPowerShell and Update Code -> updateResourceActivity

The only parameter required was the powershell script - I opted for a filename rather than including the script - no further parameters required.  The powershell script can the access and modify all members of $workflowdata and $target, and also read $request.  Some sample powershell possible is shown below:

# Output current request information to some log files
$workflowdata | out-File "C:\fimlogs\troubleshoot-workflowdata.txt"
$request | out-File "C:\fimlogs\troubleshoot-request.txt"
$target | out-File "C:\fimlogs\troubleshoot-target.txt"

if ($request.Get_Item("ObjectType") == "Person")) {
  $target.Set_Item("OfficeLocation","Monte Carlo")  
  $workflowdata.Add_Item("ACTION","Office Location Updated")
Hopefully this will be the only workflow I have to code in Visual Studio, I agree with your comment on the front page, that these workflows are completely the 
wrong approach for the intended application.  
Mar 6, 2011 at 11:27 PM

Awesome idea Jason, want to make the change to this project?