Issue with powershell script in workflow.
I have a script I would like run when a workitem is changed. I am able to trigger the work flow correctly, and I can get the script to run by running an instance:
<AssemblyName>Cireson.Powershell.Activity.Workflow</AssemblyName> <WorkflowTypeName>Cireson.Powershell.Activity.Workflow.RunPowershellScript</WorkflowTypeName> <WorkflowParameters> </WorkflowArrayParameter> <WorkflowArrayParameter Name="InstanceId" Type="guid"> <Item>284ce973-3422-7e7f-4bf0-b558c187190f</Item> </WorkflowArrayParameter> </WorkflowParameters>
However this just runs that instance and doesn't change parameters based on the workitem. I tried to replace "InstanceId" with just "Id" to no avail. Is there a way that I can run the actual script and not just a certain instance of it?
Answers
Wow @Eric_Evans
Your question has blown my mind. I'm not even sure how this works but I love your thinking. I'm going to investigate tomorrow.
Geoff
Haha well, be careful, I have been down this rabbit hole all day.
I'll let you know IF I get anywhere
Hi @Eric_Evans
The workflow is designed to take the Id of a PowerShell Activity object, read the related script and figure out the params based on the context of where the Activity sits.
What you are trying to do is genius, but sadly not possible. Yet...
Geoff
@Geoff_Ross
Thank you so much for the kind words. I have figured out a way to do what I need (in theory) I have yet to make a proof of concept (hope to tonight). Here is the idea:
1. Make a template that has predefined parameters.
2. Make a workflow that when a condition is met (Priority = Medium) the template will be applied.
3. Make a workflow with a script that will search for those parameters and pull in the information. once you have the information, you are free to what you wish. After you do what you need to do, have the script to set the work item’s template back to the original.
This workaround will take some time to build out, but I do think it will work for what I need. Also, this idea will not work for more than one work item at a time (since the whole thing hinges on finding that unique factor in the template), if more than one work item has that factor set, it might not get the right information.
What if there was a separate custom workflow that took three parameter
Then as long as your Param matches on the PS:
Then you can read the rest of the properties from the IR in the PS.
Does that sound interesting?
@Geoff_Ross I am sorry, priorities have led me elsewhere at this time. I hope to revisit this idea soon thank you for your help so far.
Hey Eric,
I remembered this thread when I saw your name pop up. I have a solution here if you want to have a play?
Place this DLL in your ServiceManager installation folder and then you can use it in your custom workflow MP.
Replace your Write Action as follows: