Configuring a Custom Web Page
Workflow Manager
There are a number of steps involved before a custom web page can be launched by a Custom Web Page workflow step. Information about configuring a Custom Web Page as a workflow step is presented in the following sections:
• | Parameters |
• | Web Methods |
• | HTTP GET Protocol Example |
Workflow Manager sends the web service location and the web method in the query string to the external custom web page. The key value is WebServiceURL. This key has both the web service and the web method, in the format webservicelocation/webMethod. The following other parameters also need to be passed through the query string:
Parameter |
Description |
|||||||||
ApplicationID |
The unique identifier for the workflow request in the Workflow Manager database. |
|||||||||
WFMajorItemID |
The unique identifier for the workflow phase in the Workflow Manager database. |
|||||||||
WFMinorItemID |
The unique identifier for the workflow step in the Workflow Manager database. |
|||||||||
PersonID |
The unique identifier in the Workflow Manager database for the account of the person currently completing the workflow request. |
|||||||||
MinorType |
The workflow step type, which always needs to be set to 10 (Custom Step Type). |
|||||||||
EditType |
Your custom web page may perform differently, depending on what mode it is called in. Choose one of the following modes:
|
When configuring a custom web page, you may need to implement the following Web methods:
• | AdvanceWFMinorStep |
• | RollbackWFMinorStep |
• | EditWFMinorStep |
Once the consumer completes your custom web page, this method will be called to advance the workflow request to the next workflow step. If your web page is the last step in a workflow phase, this method also needs to advance the request to its next workflow phase.
Parameter Type |
Parameter |
Description |
||||||
Input |
strAppID |
The unique identifier for the workflow request in the Workflow Manager database. |
||||||
strWFMajorItemID |
The unique identifier for the workflow phase in the Workflow Manager database, which contains the workflow step launching your web page. |
|||||||
strWFMinorItemID |
The unique identifier for the workflow step in the Workflow Manager database which launches your web page. This should be the current step in progress. |
|||||||
strPersonID |
The unique identifier in the Workflow Manager database for the account of the person currently completing the workflow request. |
|||||||
nWFMinorType |
The workflow step type - always needs to be set to 10 (Custom Step Type). |
|||||||
Output |
boolean |
The return value of AdvanceWFMinorStep should be:
|
This method rolls back the workflow request to the workflow step which launches your workflow request.
Parameter Type |
Parameter |
Description |
||||||
Input |
strAppID |
The unique identifier for the workflow request in the Workflow Manager database. |
||||||
strWFMajorItemID |
The unique identifier for the workflow phase in the Workflow Manager database, which contains the workflow step launching your web page. |
|||||||
strWFMinorItemID |
The unique identifier for the workflow step in the Workflow Manager database which launches your web page. The workflow request will be rolled back to this step. |
|||||||
strPersonID |
The unique identifier in the Workflow Manager database for the account of the person currently completing the workflow request. |
|||||||
nWFMinorType |
The workflow step type - always needs to be set to 10 (Custom Step Type). |
|||||||
Output |
boolean |
The return value of RollbackWFMinorStep should be:
|
This method updates the workflow step (by launching your workflow request again) after it has already been completed. Implement this method if you want to be able to relaunch your web page after it has been completed without having to roll back to its workflow step.
Parameter Type |
Parameter |
Description |
||||||
Input |
strAppID |
The unique identifier for the workflow request in the Workflow Manager database. |
||||||
strWFMajorItemID |
The unique identifier for the workflow phase in the Workflow Manager database, which contains the workflow step launching your web page. |
|||||||
strWFMinorItemID |
The unique identifier for the workflow step in the Workflow Manager database which launches your web page. |
|||||||
strPersonID |
The unique identifier in the Workflow Manager database for the account of the person currently completing the workflow request. |
|||||||
nWFMinorType |
The workflow step type - always needs to be set to 10 (Custom Step Type). |
|||||||
Output |
boolean |
The return value of EditWFMinorStep should be:
|
Note:When an action has been performed on a custom web page, you may need to manually refresh the Workflow Manager Workflow Request page to see any changes (such as completing or rolling back to the web page’s workflow step).
The example below shows you how to create a custom web page using the HTTP GET protocol for consuming a web service. Other protocols can also be used, like HTTP POST and SOAP.
-------- Code Example for implementing the web service --------------
//This method is called when page is loaded
void Page_Load(Object sender, EventArgs e)
{
//Displaying all the information received in the page from the Workflow Manager system through
//the URL for consumption of web services
//Web Service Location
this.lblWebServLocTxt.Text = HttpContext.Current.Request.QueryString["WebServiceURL"];
this.strWebServiceLoac = HttpContext.Current.Request.QueryString["WebServiceURL"];
//Application ID
this.lblAppIdTxt.Text = HttpContext.Current.Request.QueryString["ApplicationID"];
this.strAppId = HttpContext.Current.Request.QueryString["ApplicationID"];
//Major Item Id
this.lblMajorItemIdTxt.Text = HttpContext.Current.Request.QueryString["WFMajorItemID"];
this.strWFMajorItemID = HttpContext.Current.Request.QueryString["WFMajorItemID"];
//Minor Item Id
this.lblMinorItemTxt.Text = HttpContext.Current.Request.QueryString["WFMinorItemID"];
this.strWFMinorItemID = HttpContext.Current.Request.QueryString["WFMinorItemID"];
//Minor Type
this.lblMinorTypeTxt.Text = HttpContext.Current.Request.QueryString["MinorType"];
this.strWFMinorType = HttpContext.Current.Request.QueryString["MinorType"];
//Person Id
this.lblPersonIdTxt.Text = HttpContext.Current.Request.QueryString["PersonID"];
this.strPersonID = HttpContext.Current.Request.QueryString["PersonID"];;
//Mode (New:Advance work flow ; Edit:Editing the Step; Rollback:Rollback)
this.lblModeTxt.Text =HttpContext.Current.Request.QueryString["EditType"];
this.strEditType = HttpContext.Current.Request.QueryString["EditType"];
//Clearing any previous error
lblErr.Text = "";
//Changing the name of the Submit button according to the edit mode
if(strEditType == "New")
this.btnSubmit.Text = "Advance WorkFlow";
else if(strEditType == "Edit")
this.btnSubmit.Text = "Edit Custom Step";
else if(strEditType == "Rollback")
this.btnSubmit.Text = "Rollback";
}
//This method is called when Submit button is clicked
private void btnSubmit_Click(object sender, System.EventArgs e)
{
string retStr = "false";//String to hold return value of Web service called
/*
HTTP GET method is used for consuming the Web service
1. Query string containing all key value collection for the method signature of
the web service's web method is created
2. The query string is concatenated with "webservicelocation/webMethod"
3. A web request is sent to the web service.
4. The response is stored in an XML document and, using XPath query, the result is found.
5. The result is checked for True value, and if True, the parent page is refreshed and the
present page is closed.
*/
//Query String containing all key value collection for the method signature
// of the web service's webmethod is created
string querystring ="strAppID=" + this.strAppId + "&WFMajorItemID=" + this.strWFMajorItemID +
"&WFMinorItemID="+ this.strWFMinorItemID + "&PersonID="+ this.strPersonID +
"&nWFMinorType="+ this.strWFMinorType ;
//The query string is concatenated with "webservicelocation/webMethod"
string uri = this.strWebServiceLoac +"?"+ querystring;
try
{
//A web request of "GET" type is created.
System.Net.WebRequest newReq = WebRequest.Create(uri);
newReq.Method = "GET";
//A web request is send to the web service and the web response is stored in ReceiveStream.
WebResponse res = newReq.GetResponse();
Stream ReceiveStream = res.GetResponseStream();
//The response is converted into XML document
XPathDocument document = new XPathDocument(ReceiveStream);
//XML navigator is created for using XPath query in the XML document to find the result
XPathNavigator nav = document.CreateNavigator();
//XML document is queried for the result of the webmethod ("bool")
XPathNodeIterator nodes = nav.Select("//bool");
//Result is stored in the retStr string
retStr = nodes.Current.Value;
}
catch(Exception ex)
{
//Displaying the exception error
lblErr.Text = ex.Message;
}
//If the result of the web method of the web service is true, then do the follwing
//1. Refresh the parent window of window.opener.location = window.opener.location.href
// refreshes the Workflow Manager page which opened the current page.
//2. Close the present window (self.close()).
//Note: If we do not refresh the parent window, then we will not be able to see
//the changes of the web service in Workflow Manager.
if(retStr.Trim() == "true")
{
StringBuilder sb = new StringBuilder();
sb.Append("<SCRIPT>window.opener.location = window.opener.location.href;
self.close();<" + "/SCRIPT>");
this.Page.RegisterClientScriptBlock("customWebPageScript",sb.ToString());
}
}
See Also
Defining a Web Service Call Element
Defining a Custom Web Page Workflow Step
Defining Specialized Data Elements, Workflow Phases, and Workflow Steps