Defining a Custom Automated Task Workflow Step

Workflow Manager

Workflow tasks often require you to launch other executables or tasks which are performed outside of Workflow Manager itself. Using a Custom Automated Task workflow step, you can instruct Workflow Manager to automatically execute a task outside of Workflow Manager.

About Custom Automated Tasks
Defining a Custom Automated Task Workflow Step
Sample iPlugin File: TestPlugin.cs

About Custom Automated Tasks

Using a Custom Automated Task workflow step enables you to run your own custom code using the iPlugin infrastructure and advance the workflow to the next step, all without manual intervention.

A workflow step of type Custom Automated Task prompts Workflow Manager to use the AppWorkflowStepInitiated method in the iPlugin infrastructure to automatically complete a task (by executing custom code) and to mark the workflow step as complete.

You could use a Custom Automated Task workflow step to execute some custom code that would update a third party database. But, even without writing any custom code, you can use the provided sample Custom Automated Task for a workflow step that would simply mark the step complete, which would trigger automatic email notification (if notification is configured to occur whenever a workflow step is completed).

By default, the Custom Automated Task Status dialog box, which opens after a Custom Automated Task workflow step has completed, notifies the user that the step was completed successfully. However, you can create your own ASPX page that would, for example, query a third party system and display results.

Defining a Custom Automated Task Workflow Step

To define a workflow step with a Step Type of Custom Automated Task, perform the following steps:

To define a Custom Automated Task workflow step:

1. Open a workflow template on the Template Details page, as described in Creating a New Template.
2. Add a new workflow step.
3. Enter a name for this workflow step in the Workflow Step Description field.
4. Set Step type to Custom Automated Task.
5. In the Custom Site URL field, enter a URL to the page that you want to be displayed to show the results of the execution of the automated task. By default, the following ASPX page is provided:

http://IPADDRESS/CustomWorkflow/CustomAutomatedTaskStatus.aspx

Note:By default, the value of the Custom Site URL field begins with either localhost or an IP address. In order for this workflow step to work, this value must be modified to point to your Workflow Manager server.

Note:If you use this default ASPX page, the following page will open after this workflow step is automatically completed:

6. Write the custom API code that you want to be executed when this task is performed. For instructions on writing this code, see Sample iPlugin File: TestPlugin.cs.

Note:If you just use the sample code that is provided for this Custom Automated Task workflow step, Workflow Manager would simply mark the step complete, which would trigger automatic email notification (if notification is configured to occur whenever a workflow step is completed).

Sample iPlugin File: TestPlugin.cs

You can obtain a sample iPlugin file named TestPlugin.cs from Flexera Technical Support. This TestPlugin.cs file contains sample code to use when defining a Custom Automated Task. You need to add your code to the DoCustomAutomatedTask private method. Below is a sample of the code in the this file:

private void DoCustomAutomatedTask(string appXMLInfo, string ApplicationID, AesSession session)

    {

        try

        {

            string phaseID = GetValue(appXMLInfo, "PhaseID");

            TraceSink("DoSynchronousAutomatedTask Called for Application ID " + ApplicationID + "
                & PhaseID:" + phaseID);

 

            string stepID = GetValue(appXMLInfo, "StepID");

            TraceSink("DoSynchronousAutomatedTask Called for Application ID " + ApplicationID + "
                & StepID:" + stepID);

 

            string stepName = GetValue(appXMLInfo, "StepName");

            TraceSink("DoSynchronousAutomatedTask Called for Application ID " + ApplicationID + "
                & StepName:" + stepName);

 

            TraceSink("DoSynchronousAutomatedTask:: Getting a ApplicationRequest Object");

            AdminStudio.Public.WorkflowManager.ApplicationRequest AR =
                AdminStudio.Public.WorkflowManager.ApplicationRequest.Load(session, ApplicationID);

 

            if (null == AR)

            {

                TraceSink("DoSynchronousAutomatedTask:: Got a NULL ApplicationRequest Object");

                return;

            }

 

            //  Write your custom code here

            //  You can conditionally run the code based on the phaseId/stepID/stepName

            //  for a specific step

            //  You can also save the results in the DataText field for the WF Step that will be

            //  displayed in the custom edit page.

            //  A sample COMMENTED code is shown below how you would do a assignment

            /*

            if (stepName.Equals("Acknowledge Request", StringComparison.InvariantCultureIgnoreCase))

            {

                string userName = AR.GetDataItem("System Administrator", "Requester Details");

                if (!String.IsNullOrEmpty(userName))

                {

                    AR.SetWorkAssignments(CompanyType.Servicer, "System Administrator", userName);

                }

            }*/

 

            //  Any status text set here will be visible when the user selects the link on the

            //  custom automated step.

            string status = "Completed Successfully";

            AR.SetWorkflowItem(stepID, status);

            AR.Save();

 

            TraceSink("DoSynchronousAutomatedTask:: Advancing Workflow");

            AR.AdvanceWorkflow();

        }

        catch (Exception e)

        {

            TraceSink("DoSynchronousAutomatedTask threw Exception: " + e.Message);

            TraceSink("DoSynchronousAutomatedTask StackTrace: " + e.StackTrace);

        }

    }

Note:You can use the iPlugin architecture to write any custom code to associate with this automated task. You can write code to perform a task or just to display some information to the user. For more information, see Using the IPlugin Interface.

See Also