Datapolis Process System SDK

Search:

Contents
:
IndexBookmarkPrint
Home > Custom Forms > Custom Form Code

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

  • Datapolis.WorkBox.Common  - it provides useful methods e.g. logger
  • Datapolis.WorkBox.Utilities - methods needed to manage workflows

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);
}

 

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:

  • List - the GUID of the list on which the workflow definition is deployed;
  • WorkflowID - the workflow's ID;
  • ItemID - the ID of the list item on which the workflow is to be started;
  • ActionName - human readable name of started action
  • SourceURL - URL address of the source page;
  • RedirectURL - URL address of the page to which users should be redirected after the workflow has been successfully started.

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"];
    }
}