Datapolis Process System SDK
Custom Form Code
Below you will find basic information about coding custom forms in Datapolis Process System.
Requirements
To code custom control you need the following references in your SharePoint solution project
The first assembly can be found in GAC after DPS is installed.
The second can be downloaded here [ Link in development ]. Remember that every file in SDK can also be found in Download section.
Implementation
Coding a custom control requires developing a SharePoint Application Page, which launches an action and redirects to an appropriate page.
WBInterface.WBInterfaceManager _interfaceManager = new Datapolis.WorkBox.Common.WBInterface.WBInterfaceManager(SPContext.Current.Web); //launch action WBInterface.WBResultInfo resultInfo = _interfaceManager.LaunchWBAction(_workflowID, _actionInfo); if (resultInfo.Result == true) { //action launched if (string.IsNullOrEmpty(_redirectUrl)) this.Page.Response.Redirect(_workflowInfo.ListDefaultViewUrl); else this.Page.Response.Redirect(_redirectUrl); } else { //action not launched throw new Exception("Action was not launched. Error: " + resultInfo.Message); }
WBInterface.WBInterfaceManager _interfaceManager =
new
Datapolis.WorkBox.Common.WBInterface.WBInterfaceManager(SPContext.Current.Web);
//launch action
WBInterface.WBResultInfo resultInfo = _interfaceManager.LaunchWBAction(_workflowID, _actionInfo);
if
(resultInfo.Result ==
true
)
{
//action launched
(
string
.IsNullOrEmpty(_redirectUrl))
this
.Page.Response.Redirect(_workflowInfo.ListDefaultViewUrl);
else
.Page.Response.Redirect(_redirectUrl);
}
//action not launched
throw
Exception(
"Action was not launched. Error: "
+ resultInfo.Message);
Launching an action should be followed by redirecting to the page specified by RedirectURL parameter.
Initial Parameters
There are several parameters which are passed to the page through the GET method (i.e. in the URL); for instance, if we have published a MyCustomForm.aspx page on IIS, a sample URL will look like:
http://{server}/MyCustomForm.aspx?List=value1&WorkflowID=value2&ItemID=value3&SourceURL=value4&RedirectURL=value5
Here is the list of the parameters passed via URL:
It is a good idea to store these parameters in private properties during Page Load
public partial class WorkboxCustomForm : LayoutsPageBase { private Guid _listID; private Guid _workflowID; private int _itemID; private string _actionName; private string _sourceUrl; private string _redirectUrl; protected void Page_Load(object sender, EventArgs e) { try { _listID = new Guid(Page.Request["List"]); } catch (Exception ex) { throw new Exception("List parameter was not recognized.", ex); } try { _workflowID = new Guid(Page.Request["WorkflowID"]); } catch (Exception ex) { throw new Exception("WorkflowID parameter was not recognized.", ex); } try { if (!string.IsNullOrEmpty(Page.Request["ItemID"])) _itemID = int.Parse(Page.Request["ItemID"]); else _itemID = -1; } catch (Exception ex) { throw new Exception("ItemID parameter was not recognized.", ex); } _actionName = Page.Request["ActionName"]; _sourceUrl = Page.Request["SourceURL"]; _redirectUrl = Page.Request["RedirectURL"]; } }
public
partial
class
WorkboxCustomForm : LayoutsPageBase
private
Guid _listID;
Guid _workflowID;
int
_itemID;
_actionName;
_sourceUrl;
_redirectUrl;
protected
void
Page_Load(
object
sender, EventArgs e)
try
_listID =
Guid(Page.Request[
"List"
]);
catch
(Exception ex)
"List parameter was not recognized."
, ex);
_workflowID =
"WorkflowID"
"WorkflowID parameter was not recognized."
(!
.IsNullOrEmpty(Page.Request[
"ItemID"
]))
_itemID =
.Parse(Page.Request[
_itemID = -1;
"ItemID parameter was not recognized."
_actionName = Page.Request[
"ActionName"
];
_sourceUrl = Page.Request[
"SourceURL"
_redirectUrl = Page.Request[
"RedirectURL"