cancel
Showing results for 
Search instead for 
Did you mean: 

How to Automatically create Workflow Requests using WorkFlow Manager web services in Powershell

How to Automatically create Workflow Requests using WorkFlow Manager web services in Powershell

Summary

WorkFlow Manager (WFM) does provide web services using which one can automate many Workflow related tasks in WFM. The list of all web methods available can be found from browsing to the Integration.asmx file (http:///WebServicesRoot/Integration.asmx) through Internet Explorer.

Synopsis

WorkFlow Manager (WFM) does provide web services, which one can use to automate many Workflow related tasks in WFM. The list of all web methods available can be found from browsing to the Integration.asmx file (http://<WFM_Server>/WebServicesRoot/Integration.asmx) through Internet Explorer.

In this article, we will discuss on how to automatically create a workflow request using some of the methods available in the Integration.asmx, particularly the new SetMultipleDataElements method introduced in WFM 2013 R2. We will use Powershell to demonstrate the use of WFM web service calls.

Discussion

The following Powershell Script can be used to submit a workflow request automatically. The comments in the script, explains the each individual line in the code. You will have to change the parameters passed to each web method, to match to your local WFM configuration.
#Beginning of Powershell Script

# Working example of how to use PowerShell (version >= 2) to access a web service.
# Create an object to use and access the web methods available in WFM web service Integration.asmx
# Replace WFM_Server in the following line, with your WFM Server IP or DNS name
$WFMwebsvc = New-WebServiceProxy ?Uri ?http://<WFM_Server>/WebServicesRoot/Integration.asmx? 

# Create a cookie container object to enable stateful communication 
$WFMwebsvc.CookieContainer = New-Object System.Net.CookieContainer

# Authenticate against WFM using a database user
$WFMwebsvc.AuthenticateDBUser("admin@wfm.com","admin")

# Create a Workflow request, using the existing Project Name and the desired new Workflow Name
$strCreateWFReturn = $WFMwebsvc.CreateWorkflowRequest("Project Automation", "TestSample")

# Provide the initial data entry group values in the form of a xml string - ="<XML><DataGroup Name=""><Element Name="" Value=""/><Element Name="" Value=""/></DataGroup></XML>"
# You will have to use ` character to escape the double quotes inside the XML string
$WFMwebsvc.SetMultipleDataElements("<XML><DataGroup Name=`"Group1`"><Element Name=`"Enter Name`" Value=`"ABC`"/><Element Name=`"Enter Role`" Value=`"IT`"/></DataGroup></XML>")

# Submit the workflow request 
$WFMwebsvc.SubmitWorkflowRequest("True")

#End of Powershell Script

Additional Information

For more information about stateful communication between a web client and web service, refer to the article --> Microsoft article on System.Net.CookieContainer class

For more information on WFM, refer to the help --> WorkFlow Manager 2013 R2 Help Library
Labels (1)
Was this article helpful? Yes No
No ratings