Datapolis Process System SDK
Creating Custom Form Walkthrough
This walkthrough will guide you through creating a custom form. The form consists of textbox with label and action launch button.
​
Prerequisites
Add application page
Firstly add Layouts mapped folder to solution.
Then to Layouts folder add new item.
Choose Application page and add new form. In this example it will be named WorkboxCustomForm.aspx.
New empty application page has been created. This page will be used later as our action form.
Develop control
<
asp:Content
ID
=
"PageHead"
ContentPlaceHolderID
"PlaceHolderAdditionalPageHead"
runat
"server"
>
</
"Main"
"PlaceHolderMain"
asp:Label
"lblSomeParameter"
Text
"Some parameter"
></
asp:TextBox
"tbxSomeParameter"
br
/>
asp:Button
"btnLaunchAction"
"Launch action"
"PageTitle"
"PlaceHolderPageTitle"
Workbox Custom Form
"PageTitleInTitleArea"
"PlaceHolderPageTitleInTitleArea"
Edit code behind
Open WorkboxCustomForm.aspx.cs file. It should look like below. Add using statement for Datapolis.WorkBox.Common namespace.
using
System;
Microsoft.SharePoint;
Datapolis.WorkBox.Common.Security;
namespace
WorkboxCustomForm.Layouts.WorkboxCustomForm
{
public
partial
class
WorkboxCustomForm : LayoutsPageBase
}
Now add parsing of form parameters. When you choose a custom form to be used as an action form then several parameters will be added to url when user clicks action and workflow redirects to your page. Those parameters describes the action. You need to parse those parameters to check which action and in which workflow the form should show.
Microsoft.SharePoint.WebControls;
#region Private Fields
private
Guid _listID;
Guid _workflowID;
int
_itemID;
string
_actionName;
_sourceUrl;
_redirectUrl;
#endregion
protected
void
Page_Load(
object
sender, EventArgs e)
#region Request parameters
try
_listID =
new
Guid(Page.Request[
"List"
]);
catch
(Exception ex)
throw
Exception(
"List parameter was not recognized"
, ex);
_workflowID =
"workflowID"
"WorkflowID parameter was not recognized."
if
(!
.IsNullOrEmpty(Page.Request[
"ItemID"
]))
_itemID =
.Parse(Page.Request[
else
_itemID = -1;
"WorkflowID parameter was not recognized"
_actionName = Page.Request[
"ActionName"
];
_sourceUrl = Page.Request[
"SourceUrl"
_redirectUrl = Page.Request[
"RedirectUrl"
Now we will add fields containing WBInterface classes. Those object contains WBInterface manager class and action and its parameter.
Datapolis.WorkBox.Common.WBInterface.WBInterfaceManager _interfaceManager;
Datapolis.WorkBox.Utilities.WBInterface.WBWorkflowInfo _workflowInfo;
Datapolis.WorkBox.Utilities.WBInterface.WBActionInfo _actionInfo;
Datapolis.WorkBox.Utilities.WBInterface.WBActionParameter _actionParameter;
Then in Load page method interface manager will be opened and action will be loaded. Also textbox will be filled with data from action parameter.
#region Fill parameter
_interfaceManager =
Datapolis.WorkBox.Common.WBInterface.WBInterfaceManager(SPContext.Current.Web);
_interfaceManager.GetWBSiteInfo();
_workflowInfo = _interfaceManager.GetWBWorkflowInfo(_workflowID);
_actionInfo = _workflowInfo.WorkflowActions[_actionName];
_actionParameter = _actionInfo.Parameters[
"SomeParameter"
(_actionParameter !=
null
)
tbxSomeParameter.Text = _actionParameter.Properties[
"DefaultValue"
].ToString();
Next fill button click event. In this event text provided in textbox is written to action parameter value. Then action is launched and page is redirected.
#region Button
btnLaunchAction.Click += btnLaunchAction_Click;
btnLaunchAction_Click(
_actionParameter.Value = tbxSomeParameter.Text;
Datapolis.WorkBox.Utilities.WBInterface.WBResultInfo resultInfo = _interfaceManager.LaunchWBAction(_workflowID, _actionInfo);
(resultInfo.Result ==
true
(
.IsNullOrEmpty(_redirectUrl))
this
.Page.Response.Redirect(_workflowInfo.ListDefaultViewUrl);
.Page.Response.Redirect(_redirectUrl);
"Action was not launched. Error: "
+ resultInfo.Message);
Deploy
To deploy solution – so your form will be available on SharePoint – just right click on solution and choose deploy.
Next Steps
Optionally, after reading this walkthrough you can see the same custom form code attached in SDK Samples in Download section.