Datapolis Process System SDK
Control Code
Below you will find basic information about coding custom controls in Datapolis Process System.
Requirements
To code custom control you need the following reference in your SharePoint solution project
This assembly can be found in GAC after Datapolis Process System is installed.
Implementation
Coding a custom control requires developing a SharePoint User Control that inherits from base class supplied by Datapolis Process System: WBCustomFieldControlBase
public
partial
class
MyCustomFieldControl : WBCustomFieldControlBase
{
protected
void
Page_Load(
object
sender, EventArgs e)
}
You need to override 4 methods from base class which contains:
Since custom control is in fact user control it uses ascx markup. Example will consist of one textbox and one dropdown list.
<
asp:TextBox
runat
=
"server"
ID
"tbMyValue"
Text
""
/>
asp:DropDownList
"ddlMyType"
>
</
Overriding methods
First method is SetDefaultValue. It runs when the form is loaded with current value of workflow variable as an argument.
override
SetDefaultValue(
string
value)
// store default value passed from launch form
_myValue =
new
MyValue(value);
// set controls values
tbMyValue.Text = _myValue.Value;
ddlMyType.SelectedValue = _myValue.Type.ToString();
Second method is GetValue. It passes control value to workflow variable. Internally all workflow variables are strings, so you have to parse your value to formatted string.
GetValue()
// get values from form
_myValue.Type = (MyDataType)Enum.Parse(
typeof
(MyDataType), ddlMyType.SelectedValue);
_myValue.Value = tbMyValue.Text;
// return formated
return
_myValue.ToString();
Third method is IsRequired. Its purpose is to indicate if a * will be displayed next to field title.
bool
IsRequired()
false
;
Last method is Validate. Validation occurs after clicking "Confirm" button on form. If this method returns true, the value will be passed, and the form will be closed. Otherwise validationErrorMsg will be displayed.
Validate(
out
validationErrorMsg)
// validate value by selected type
validationErrorMsg = String.Empty;
isValid =
MyDataType type = (MyDataType)Enum.Parse(
switch
(type)
case
MyDataType.Integer:
int
intVal;
if
(
.TryParse(tbMyValue.Text,
intVal))
true
else
validationErrorMsg =
"Expected integer value."
break
//...
isValid;