Class: FieldModel

documents.sdk FieldModel

Constructors

The FieldModel is the abstract model for form fields. It provides various methods to inspect and manipulate the field model data.
Every FieldModel is a Backbone.Model.

Members

TypesString

enumeration of different field types.

Properties:
Name Type Default Description
CHECKBOX String CHECKBOX
CUSTOM String CUSTOM
DATE String DATE
DOUBLE_LIST String DOUBLE_LIST
EMAIL String EMAIL
ENUM String ENUM
FILING_PLAN String FILING_PLAN
GADGET String GADGET
HISTORY String HISTORY
HTML String HTML
NUMBER String NUMBER
PASSWORD String PASSWORD
RADIO String RADIO
REFERENCE String REFERENCE
SEPARATOR String SEPARATOR
STRING String STRING
TEXT String TEXT
TEXT_FIXED String TEXT_FIXED
TIMESTAMP String TIMESTAMP
URL String URL

Methods

getBgColor(){String}

Returns the background color of the field.

Returns:
Type Description
String the field background color

getBorderColor(){String}

Returns the border color of the field.

Returns:
Type Description
String the field border color

getColor(){String}

Returns the font color of the field.

Returns:
Type Description
String the field font color

getEnumValues(){Array.<Object>}

Returns the optional enum values of the field.

Returns:
Type Description
Array.<Object> the field enum values
Example
Return format:
[{"label" : "label1", "selected": false, "value": "value1"}, {"label" : "label2", "selected": true, "value": "value2"}, ...]

getId(){String}

Returns the id of the field.

Returns:
Type Description
String the field id

getLabel(){String}

Returns the label of the field.

Returns:
Type Description
String the field label

getLabelColor(){String}

Returns the font color of the fields label.

Returns:
Type Description
String the font color of the fields label

getName(){String}

Returns the technical name of the field.

Returns:
Type Description
String the technical field name

getTooltip(){String}

Returns the tooltip of the field.

Returns:
Type Description
String the field tooltip

getType(){String}

Returns the type of the field.

Returns:
Type Description
String the field type

getValue(){String|Array.<String>|Boolean}

Returns the value(s) of the field.

Returns:
Type Description
String | Array.<String> | Boolean the field value

isGuiReadonly(){Boolean}

Returns if the field is gui readonly or not.

Returns:
Type Description
Boolean true if the field is gui readonly, false otherwise

isMandatory(){Boolean}

Returns if the field is mandatory or not.

Returns:
Type Description
Boolean true if the field is mandatory, false otherwise

isReadonly(){Boolean}

Returns if the field is readonly or not.

Returns:
Type Description
Boolean true if the field is readonly, false otherwise

isSameLine(){Boolean}

Returns if the field is in the same line as the preceding field or not.

Returns:
Type Description
Boolean true if the field is in the same line as the preceding field, false otherwise

setAutoComplete(options)

Adds autocomplete to a field. Only works for STRING fields.

Name Type Description
options Object

the autocomplete config

Name Type Description
scriptName String

the name of the script

minQueryChars Number optional

amount of letters after which autocomplete starts

queryDelay Number optional

time interval, after which autocomplete starts

maxResults Number optional

max amount of autocomplete entries

autoFocusResult Boolean optional

focus on the first autocomplete entry

Example
documents.sdk.exitRegistry.registerSearchExitCallback("ExtendedSearch.afterSetModelData", function(documentsContext, options) {
	var fields = options.searchForm.getSearchFields();

	var field = fields.get("crmName");
	
	field.setAutoComplete({
		scriptName: "auto",
		minQueryChars: 2,
		queryDelay: 0.5,
		maxResults: 25,
		autoFocusResult: false
	})
});

setBgColor(color)

Sets the background color of the field.

Name Type Description
color String

the field background color. All color definitions available in CSS3 are supported as parameters.

Example
//the following method calls are showing different ways to change the background color to red:
field.setBgColor("red");
field.setBgColor('#FF0000');
field.setBgColor('rgb(255,0,0)');
field.setBgColor('hsl(0, 100%, 50%)');
field.setBgColor('cmyk(0%, 100%, 100%, 0%)');

setBorderColor(color)

Sets the border color of the field.

Name Type Description
color String

the field border color. All color definitions available in CSS3 are supported as parameters.

Example
//the following method calls are showing different ways to change the border color to red:
field.setBorderColor("red");
field.setBorderColor('#FF0000');
field.setBorderColor('rgb(255,0,0)');
field.setBorderColor('hsl(0, 100%, 50%)');
field.setBorderColor('cmyk(0%, 100%, 100%, 0%)');

setColor(color)

Sets the font color of the field.

Name Type Description
color String

the field font color. All color definitions available in CSS3 are supported as parameters.

Example
//the following method calls are showing different ways to change the font color to red:
field.setColor("red");
field.setColor('#FF0000');
field.setColor('rgb(255,0,0)');
field.setColor('hsl(0, 100%, 50%)');
field.setColor('cmyk(0%, 100%, 100%, 0%)');

setEnumValues(enumValues, options)

Sets the optional enum values of the field. Supported input-formats can be viewed in the examples.

Name Type Description
enumValues Object | Array.<Object> | String | Array.<String>

the field enum values

options Object

the options passed

Name Type Description
keepSelected Boolean optional

true if the current selected entry should be set as the next selected entry. If it is not included within the enumValues it will be added. Default is false.

addEmptyEntry Boolean optional

true if an empty entry should be added to the enumValues. Default is false

Examples
//  1. default enum value format
[{"label" : "label1", "selected" : false, "value" : "value1"}, {"label" : "label2", "selected" : true, "value" : "value2"}, ...]
//  2. value-only enum value formats
//    a. String
"value1,value2,..."
//    b. String[]
["value1", "value2", ...]
//  3. key-value enum value formats
//    a. String
"value1:label1,value2:label2,..."
//    b. Object
{"value1" : "label1", "value2" : "label2", ...}
//  4. localized enum value formats
//    a. String
"value1;locale1:label1;locale2:label2,value2;locale1:label1;locale2:label2,..."
//    b. String[]
["value1;locale1:label1;locale2:label2", "value2;locale1:label1;locale2:label2", ...]
//    c. Object
{"value1" : {"locale1" : "label1", "locale2" : "label2"}, "value2" : {"locale1" : "label1", "locale2" : "label2"}, ...}

setExit(options)

Sets an exit configuration of the field.
A trigger type of the exit must always be set. Valid types are focusin, focusout, change and button.
If an exit configuration is set, a corresponding field exit callback must be registered in the exitRegistry.

Name Type Description
options Object

the exit configuration options

Name Type Description
type String

the exit trigger type

image String optional

the exit button image, if the type equals button

tooltip String optional

the exit button image tooltip, if the type equals button

Examples
field.setExit({ type: "focusout" });
field.setExit({
	type: "button",
	tooltip: "search for contact",
	image: "entypo:flashlight"
});

setGuiReadonly(guiReadonly)

Sets the field to gui readonly.

Name Type Description
guiReadonly Boolean

true for gui readonly, false otherwise

setLabel(label)

Sets the label of the field.

Name Type Description
label String

the field label

setLabelColor(color)

Sets the font color of the fields label.

Name Type Description
color String

the font color of the fields label. All color definitions available in CSS3 are supported as parameters.

Example
//the following method calls are showing different ways to change the labels font color to red:
field.setLabelColor("red");
field.setLabelColor('#FF0000');
field.setLabelColor('rgb(255,0,0)');
field.setLabelColor('hsl(0, 100%, 50%)');
field.setLabelColor('cmyk(0%, 100%, 100%, 0%)');

setName(name)

Sets the technical name of the field.

Name Type Description
name String

the technical field name

setReadonly(readonly)

Sets the field to readonly.

Name Type Description
readonly Boolean

true for readonly, false otherwise

setSameLine(sameLine)

Sets the field to the same line as the preceding field.

Name Type Description
sameLine Boolean

true for same line as the preceding field, false otherwise

setTooltip(tooltip)

Sets the tooltip of the field.

Name Type Description
tooltip String

the field tooltip

setType(type)

Sets the type of the field.
In case of changing a field into a checkbox or a radio-group, the displayed options will be set to a default value. If you want to change them, please use the method setEnumValues.

Name Type Description
type FieldModel.Types

the field type

Example
// This example changes the field type to date using documents.sdk.FieldModel.Types enum.
field.setType(documents.sdk.FieldModel.Types.DATE);

//The following code can be used to change the displayed options of radio-groups or checkboxes.
field.setType(documents.sdk.FieldModel.Types.RADIO);
field.setEnumValues(["1:one","2:two"]);

setValue(value, options)

Sets the value(s) of the field.
Any matching enum values will be updated automatically.

Name Type Description
value String | Array.<String> | Boolean

the field value

options Object optional
Name Type Description
silent Boolean optional

When true the silent mode is active, no backbone events will be triggered, if the model changes