Table of Contents

Class CustomForm

Namespace
CustomFormProcessor
Assembly
PolarStudio.dll

This class is used to create custom forms that store their data in xml in a table. The table must be of a type or category that contains the definition for the form of that type/category.

public class CustomForm : XMLparent
Inheritance
CustomForm
Inherited Members
Extension Methods

Fields

AllowFieldNameCollisions

This property gets/sets if field name collissions (fields in the custom form having the same name as a field in the containing table) are allowed.

public bool AllowFieldNameCollisions

Field Value

bool

DefaultControlClass

This property gets/sets the css class to apply to controls that have no class specified.

public string DefaultControlClass

Field Value

string

ShowFullTextSearchInEditor

This property gets/sets if the editor should support full text search.

public bool ShowFullTextSearchInEditor

Field Value

bool

Properties

CompiledTemplate

This property gets the compiled form template.

public string CompiledTemplate { get; }

Property Value

string

CustomModuleCode

This property gets/set the source of the custom code module.

public string CustomModuleCode { get; set; }

Property Value

string

CustomModuleCompileError

This property get the text of the last compile error for the custom module.

public string CustomModuleCompileError { get; }

Property Value

string

CustomModuleTestExpression

The expression to test the custom module.

public string CustomModuleTestExpression { get; set; }

Property Value

string

DeleteAllowed

Gets if delete is allowed in this form.

public bool DeleteAllowed { get; }

Property Value

bool

DeleteAllowedScript

A script expression to determine if delete is allowed.

public string DeleteAllowedScript { get; }

Property Value

string

DeleteAllowedStates

States in which delete is (not) allowed

public string DeleteAllowedStates { get; }

Property Value

string

EditAllowed

Gets if edit is allowed in this form.

public bool EditAllowed { get; }

Property Value

bool

EditAllowedScript

A script expression to determine if edit is allowed.

public string EditAllowedScript { get; }

Property Value

string

EditAllowedStates

States in which edit is (not) allowed

public string EditAllowedStates { get; }

Property Value

string

Fields

Gets the custom fields in this custom form.

public Collection<CustomFormField> Fields { get; }

Property Value

Collection<CustomFormField>

FormAnalysis

This property gets the analysis of the last compiled form design template.

public string FormAnalysis { get; }

Property Value

string

FormDesignTemplate

This property gets/set the form design template.

public string FormDesignTemplate { get; set; }

Property Value

string

FormStorageFieldName

Gets the name of the field to store the form data in.

public string FormStorageFieldName { get; }

Property Value

string

ParentForm

Gets the parent custom form (if applicable).

public CustomForm ParentForm { get; }

Property Value

CustomForm

StateFieldName

Returns the name of the state field.

public string StateFieldName { get; }

Property Value

string

XML

This method returns the full xml of the data stored in the custom form.

public string XML { get; }

Property Value

string

Methods

AddField(string, string, string)

This method creates a custom form field (or updates its type). If a new field is created but data for that field is already existing in the data xml, this value is used.

public CustomFormField AddField(string pFieldName, string pFieldType, string pFieldSubType = "")

Parameters

pFieldName string

The name of the field to create or update.

pFieldType string

The field type to use.

pFieldSubType string

The field sub type to use.

Returns

CustomFormField

The new or updated field.

Alive()

This property always returns True. Is used to check if the object is still alive.

public bool Alive()

Returns

bool

True

AutoInitialise(Context, string, string, string, string, string, string, string, long, string, bool, string, bool)

This method is used to quickly initialize the Custom Form when accessed.

public object AutoInitialise(Context pContext, string pFormTypeIDfieldName = "", string pFormTypeTableName = "", string pFormTypeTablePKfieldName = "", string pFormTypeTableFormDefFieldName = "", string pFormTableName = "", string pFormStorageFieldName = "", string pFormStartedScriptExpression = "", long pForcedFormTypeID = 0, string pParentFormTypeFieldName = "", bool pAutoCreateDefaultFormTemplates = false, string pStateFieldName = "", bool pSuppressScriptedEvents = false)

Parameters

pContext Context

The Context.

pFormTypeIDfieldName string

The name of the foreign key holding the type of a record in this table (like 'CustomerTypeID').

pFormTypeTableName string

The name of the table describing the type of record in this table (like 'CustomerType').

pFormTypeTablePKfieldName string

The name of the primary key in the type-table (like 'CustomerTypeID')

pFormTypeTableFormDefFieldName string

The name of the form definition field in the type-table (like 'CustomFormDefinition')

pFormTableName string

The name of the 'current' table (Like 'Customer')

pFormStorageFieldName string

The name of the field in the current table that contains the xml data for the custom form (like 'CustomForm')

pFormStartedScriptExpression string

A script expression that returns a boolean to indicate if the work in the record has 'started'. This can set specific permissions. Leave empty if you dont know what to do with it.

pForcedFormTypeID long

An optional ID for force a specific form type.

pParentFormTypeFieldName string

The name of the ParentType-field in the type table when a recursive type is used (like 'ParentCustomerTypeID')

pAutoCreateDefaultFormTemplates bool

A boolean indicating default form templates are to be created if no form templates are set in the form-definition. May result in rough forms.

pStateFieldName string

The name of the state field to use for workflow.

pSuppressScriptedEvents bool

Used internally for recursive types. Keep as False.

Returns

object

CalculateCalculatedFields(Context)

This method calculates the values of calculated fields.

public string CalculateCalculatedFields(Context pContext)

Parameters

pContext Context

The context.

Returns

string

An empty string.

CancelUpdate(Context)

This method is to be called in the OnCancel event in the form to reset the form to the original values.

public void CancelUpdate(Context pContext)

Parameters

pContext Context

The context

CheckRequiredFields(Context, ref int, ref string, string)

This method is to be called in the OnUpdate event of the dataset and checks for required fields.

public object CheckRequiredFields(Context pContext, ref int pFieldListCount, ref string pFieldList, string pFieldSeparator = "")

Parameters

pContext Context

The context.

pFieldListCount int

By ref int parameter that will be set to the number of missing required fields.

pFieldList string

By ref string parameter that will be set to the names of the missing fields.

pFieldSeparator string

An optional string used to separate the fields returned in pFieldList. Defaults to ', '

Returns

object

CheckState(Context, string)

This method checks if the current state matches the specied state(s).

public bool CheckState(Context pContext, string pStates)

Parameters

pContext Context

The context

pStates string

The state(s) to match, like: "New,InProgress,Done" or "!Cancelled,Rejected"

Returns

bool

CodedVersion()

This method returns the version of this library coded as 1.2.3

public string CodedVersion()

Returns

string

A string with the coded version

CreateCustomControl(Context, string)

This method returns the html for one custom form field.

public string CreateCustomControl(Context pContext, string pCustomControlName)

Parameters

pContext Context

The context.

pCustomControlName string

The name of the custom form field for which the html is requested.

Returns

string

The html for the control.

CreateCustomControlCaption(Context, string)

This method returns the caption of the specified custom control.

public string CreateCustomControlCaption(Context pContext, string pCustomControlName)

Parameters

pContext Context

The context

pCustomControlName string

The name of the control for which the caption is to be created.

Returns

string

The html for the caption.

CreateHTML(Context)

This method creates the html for the custom form.

public string CreateHTML(Context pContext)

Parameters

pContext Context

The context for scripts.

Returns

string

The html string.

CreateSimpleHTML(Context, string)

This method returns a simple form with the html of this custom form using bootstrap.

public string CreateSimpleHTML(Context pContext, string pFieldNames = "")

Parameters

pContext Context

The context

pFieldNames string

A list of fieldnames to get the html for. Can be preceeded by a dash (minus) character to invert the selection. Separate the names using comma's or semicolons.

Returns

string

The html for the custom fields.

CreateSimpleText(Context, int)

This method returns the contents of the form layed out as plain text.

public string CreateSimpleText(Context pContext, int pCaptionWidthCharacters = 0)

Parameters

pContext Context

The context.

pCaptionWidthCharacters int

The default width of captions in characters.

Returns

string

CustomModule(Context)

public object CustomModule(Context pContext)

Parameters

pContext Context

Returns

object

CustomModule(Context, ref string)

Returns the compiled CustomCodeModule for this custom form.

public CustomCodeModule CustomModule(Context pContext, ref string pCompileError)

Parameters

pContext Context

The context used to compile.

pCompileError string

A by ref string that is set to the compile error if applicable.

Returns

CustomCodeModule

The CustomCodeModule or Nothing in case of a compile error.

DefaultsExist(Context)

Returns true if any of the fields have a default value.

public bool DefaultsExist(Context pContext)

Parameters

pContext Context

The context.

Returns

bool

True if any of the fields have a default value.

DeleteAllowedResult(Context)

This method returns True if delete is allowed for the current record. It takes the global delete-allowed into account, the state and and DeleteAllowedScript.

public bool DeleteAllowedResult(Context pContext)

Parameters

pContext Context

The context.

Returns

bool

True if delete is allowed.

DoAction(Context, string)

This method take a specific action. Used internally.

public string DoAction(Context pContext, string pAction)

Parameters

pContext Context

The context for the action.

pAction string

The action to perform.

Returns

string

A message indicating the result.

EditAllowedResult(Context)

This method returns True if edit is allowed for the current record. It takes the global edit-allowed into account, the state and and EditAllowedScript.

public bool EditAllowedResult(Context pContext)

Parameters

pContext Context

The context.

Returns

bool

True if edit is allowed.

FillDefaults(Context, bool)

This property must be called in the OnInsert-event of the data table. It sets all defaults for custom fields.

public void FillDefaults(Context pContext, bool pForcedFill = false)

Parameters

pContext Context

The context.

pForcedFill bool

A boolean to indicate that fields must also be set to NULL/empty.

FormManipulator(Context)

This method is to be called from Polar Studio in the OnStartHTML-creation event of the data table to make sure the form is modified to the type of record.

public string FormManipulator(Context pContext)

Parameters

pContext Context

The context for the form.

Returns

string

May return a string as is returned by the OnStartHTMLcreation-event that is fired by this method.

GetCompiledTemplate(Context, string)

This method compiles the given FormDesignTemplate. Any errors will be available in the FormAnalysis property.

public string GetCompiledTemplate(Context pContext, string pFormDesignTemplate)

Parameters

pContext Context

The context to use for compilation.

pFormDesignTemplate string

The template to compile.

Returns

string

The compiled template.

GetCompiledTemplate(Context, string, ref string)

This method compiles the given FormDesignTemplate. Any errors will be available in the by-ref parameter pErrorMessages.

public string GetCompiledTemplate(Context pContext, string pFormDesignTemplate, ref string pErrorMessages)

Parameters

pContext Context

The context to use for compilation.

pFormDesignTemplate string

The template to compile.

pErrorMessages string

A by-ref parameter that will contain any error messages if applicable.

Returns

string

The compiled template.

GetCustomVariable(string, object)

This method get a custom variable from the stored xml.

public object GetCustomVariable(string pVarName, object pDefaultValue = null)

Parameters

pVarName string

The name of the custom variable.

pDefaultValue object

The value to use when the variable was not found.

Returns

object

The value of the variable or the specified default value if not found.

GetFormDesignTemplate()

Gets the FormDesignTemplate for this record.

public string GetFormDesignTemplate()

Returns

string

HasProcedure(Context, string)

This function returns True if the given procedure is implemented (in this level or a level above).

public bool HasProcedure(Context pContext, string pProcedureName)

Parameters

pContext Context

The context

pProcedureName string

The name of the procedure to check.

Returns

bool

Keep(Context)

This method keeps the values of the custom form in memory for later user.

public void Keep(Context pContext)

Parameters

pContext Context

The context.

ParseTextForIncludes(Context, string)

This method takes the input text and evaluates all embeded <%...%gt;-script expressions against the custom module.

public string ParseTextForIncludes(Context pContext, string pInputText)

Parameters

pContext Context

The context to use.

pInputText string

The text to evaluate.

Returns

string

Release(Context)

The method releases a kept record from memory for this custom form (for the current record only).

public void Release(Context pContext)

Parameters

pContext Context

The context.

ReleaseAll()

The method releases all kepts record from memory for this custom form.

public void ReleaseAll()

RemoveField(string)

This method removes the specified field.

public void RemoveField(string pFieldName)

Parameters

pFieldName string

The field to remove

ReturnPopupSelectItemData(Context, int, string, string)

This method returns the data for a SelectItemPopup as a collection

public Collection ReturnPopupSelectItemData(Context pContext, int pMaxRecordCount, string pFilter, string pSubControlName)

Parameters

pContext Context

The Context

pMaxRecordCount int

The max number of records to return.

pFilter string

A filter to search for.

pSubControlName string

An optional SubControlName

Returns

Collection

A collection with the data to show.

RunOverruledScript(Context, string)

This function only runs the top-most existing implementation of the function and then stops, even if an null result was returned

public object RunOverruledScript(Context pContext, string pScriptExpression)

Parameters

pContext Context

The context

pScriptExpression string

The expresion to evaluate.

Returns

object

The result of the script.

RunScript(Context, string)

This function will run all scripts for all levels (starting at the top-most parent) until a result (not-null-string) is given

public object RunScript(Context pContext, string pScriptExpression)

Parameters

pContext Context

The context

pScriptExpression string

The expresion to evaluate.

Returns

object

The result of the script.

ScriptEvaluate(Context, string)

This method evaluates a script in the current custom form. Errors will be ignored.

public object ScriptEvaluate(Context pContext, string pExpression)

Parameters

pContext Context

The context to use.

pExpression string

The expression to evaluate.

Returns

object

The result of the evaluation.

ScriptEvaluate(Context, string, bool)

This method evaluates a script in the current custom form.

public object ScriptEvaluate(Context pContext, string pExpression, bool pReturnErrorMessageAsResult = false)

Parameters

pContext Context

The context to use.

pExpression string

The expression to evaluate.

pReturnErrorMessageAsResult bool

A boolean indicating an error is to be returned as a message for this call.

Returns

object

The result of the evaluation.

ScriptEvaluate(Context, string, ref string, bool)

This method evaluates a script in the current custom form.

public object ScriptEvaluate(Context pContext, string pExpression, ref string pErrorMessage, bool pReturnErrorMessageAsResult = false)

Parameters

pContext Context

The context to use.

pExpression string

The expression to evaluate.

pErrorMessage string

A by ref string that will contain the error message if applicable.

pReturnErrorMessageAsResult bool

A boolean indicating an error is to be returned as a message for this call.

Returns

object

The result of the evaluation.

SetCustomVariable(string, object)

This method sets a custom variable to store in the xml.

public void SetCustomVariable(string pVarName, object pNewValue)

Parameters

pVarName string

The name of the variable.

pNewValue object

The value to store.

StoreCustomFormInFormVariables(Context)

This method stores this custom form in a variable in the web form.

public void StoreCustomFormInFormVariables(Context pContext)

Parameters

pContext Context

The context having a web form.

StoreXMLinDataBase(Context)

This method stores the values of the fields in the xml in the dataset.

public string StoreXMLinDataBase(Context pContext)

Parameters

pContext Context

The context.

Returns

string

An errormessage if applicable.

UpdateCustomFields(Context)

This method updates the custom form fields. Is used internally; no need to call manually.

public string UpdateCustomFields(Context pContext)

Parameters

pContext Context

Returns

string

Version()

This method returns the version of this library.

public string Version()

Returns

string

A string with the version