Home Service Manager

Issue with powershell script in workflow.

Eric_EvansEric_Evans Member IT Monkey ✭

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

  • Geoff_RossGeoff_Ross Cireson Consultant Super IT Monkey ✭✭✭✭✭

    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

  • Eric_EvansEric_Evans Member IT Monkey ✭

    Haha well, be careful, I have been down this rabbit hole all day.


    I'll let you know IF I get anywhere

  • Geoff_RossGeoff_Ross Cireson Consultant Super IT Monkey ✭✭✭✭✭

    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

  • Eric_EvansEric_Evans Member IT Monkey ✭
    edited September 23

    @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.

  • Geoff_RossGeoff_Ross Cireson Consultant Super IT Monkey ✭✭✭✭✭

    What if there was a separate custom workflow that took three parameter

    1. The Guid of the PS Script
    2. The Guid of the object that triggered the workflow (eg an IR)
    3. The name of the Param in the PS that should receive the Guid from 2. eg "IRGuid"

    Then as long as your Param matches on the PS:

    Param ($IRGuid)
    

    Then you can read the rest of the properties from the IR in the PS.

    Does that sound interesting?

Sign In or Register to comment.