Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This article describes the scripting functionality which can be used for data manipulation and validation in forms for objects and process tasks.

...

Note: When field data changes are made using a script (i.e., without user action) when loading the form, the Save option is not available. In contrast, you can disable fields to protect against user changes.

Script Scope 

The relevant object is given to each client script under the name 'scope.' This object provides the API so the scripts can access the object fields and their properties.

Properties of 'scope'

NameDescription
apiSupplies access to the plug-in API, with 'session' (user information), 'dms' (object details, search via DMS-Service), 'http' (connection to any service), 'config', 'util' (helper functions) and 'agent' properties.
dataSupplies all object fields defined in the object or process activity. The fields offer read-only access using the technical name. Available for release 2017-09-27 (3.22.x) or later.
modelSupplies the flattened form model and all object fields defined on the form. The fields can be accessed with the technical name. The form groups cannot be accessed in this way.
situation

Supplies the current form model situation. Scripts can respond to the relevant situation. Possible values are 'CREATE' (create), 'SEARCH' (search) and 'EDIT' (edit index data).

objectIdSupplies the ID of the current DMS object if available (available since version 6.4).

...

This section describes how to access all form elements of objects or processes.

Field Properties

The following table describes object field properties that can be accessed with 'scope.model'.

Info
titleColumn "Binding"
  1. RO (ReadOnly): ReadOnly properties can only be read. Changes to the values of RO properties do not affect the interface. 
  2. RW (ReadWrite): ReadWrite properties can also be written. Changes to the values of RW properties affect the interface.

Each field has the following properties:

NameDescriptionBinding
name

The normalized name of the fields. Normalized means the simple field name is lower case. The name must not contain special characters. This name is used to map the fields to the 'model.'

RO*
qname

The qualified name. Always <normalized type name>.'name'

Warning: The script leads to an error if qnames are not completely written in lower case

RO
labelThe display name of the type in the current user locale. Used as a field identifier.RO
descriptionA The field description . Can be used in tooltips for example.ROis shown below the form field. 
Beginning with version 10.0 and hotfix 6 of version 9.16 LTS this field is RW
RO
RW
type

Describes the data type of the field. The possible values here are documented in the description of field data types. Other field attributes may exist, depending on the data type.

RO
readonlyIf the readonly property is set to 'true,' the user cannot change the field value.RW**
requiredFlags a field as mandatory. If this property is set, the user must make an entry.RW
valueThe current value of the field.RW
multiselect

If this property for fields is set up in the schema, lists of values can be maintained. A JavaScript array is then always expected in 'value.'

Not every data type supports the 'multiselect' property.

RO

*RO (ReadOnly): ReadOnly properties can only be read. Value changes of RO properties do not affect the interface.

**RW (ReadWrite): ReadWrite properties can also be written. Value changes of RW properties affect the interface.

The following example validates dynamic field properties for required fields and write permissions.

...

NameDescriptionJavaScript data typeMulti-selection
STRINGAny text. See also datatype: STRING.StringYes
NUMBERNumber and floating point number. See also datatype: NUMBER.NumberNo
BOOLEANSimple 'on/off' or 'true/false' value.BooleanNo
DATETIMEA date or a date with time value. See also datatype: DATETIME.DateNo
CODESYSTEMAn entry from a catalog. See also datatype: CODESYSTEM.String
Must correspond with the 'data' property in the codesystem. 
Yes
TABLEA table with values. See also datatype: TABLE.Object Array
Properties of each object are defined by the column elements of the table.
No
ORGANIZATIONUser or group in the organization tree. See also datatype: ORGANIZATION.String
Corresponds to the technical name of the object in the organization.
Currently user or group names. For users, this name corresponds to the user's login name.
 
Yes

Data Type-Specific Properties

...

NameDMS description (DMS only) *1Binding
maxlenThe maximum number of characters permitted as a value in this field.RO*
minlenThe minimum number of characters permitted as a value in this field.RO
classification

If available, a specific type of text field is described.

  • 'email' to handle this as e-mail input field
  • 'url' to handle this as web address input field
  • 'selector' to handle this as a selection field that can be filled by scripting
RO

*RO (ReadOnly): ReadOnly properties can only be read.Changes to values of RO properties do not affect the interface.

**RW (ReadWrite): ReadWrite properties can also be written. Changes to values of RW properties affect the interface.

*1: Starting with release 4.3 and in case of BPM, regular expressions can be used for controlling minlen and maxlen, e.g.:

...

NameDescription (DMS only)Binding
scaleNumber of decimal places. For integer fields, this is 0.RO*
precisionTotal number of digits without separators.RO

*RO (ReadOnly): ReadOnly properties can only be read. Changes to values of RO properties do not affect the interface.


Warning

The value is not available in the 'SEARCH' situation.


DATETIME

Anchor
DATETIME
DATETIME

Expects a JavaScript 'Date' as value.

NameDescription (DMS and BPM)Binding
withtimeIs 'true' or 'false.' If 'true,' a time in seconds is expected in addition to the date.RO*

*RO (ReadOnly): ReadOnly properties can only be read. Changes to values of RO properties do not affect the interface.


Warning

The value is not available in the 'SEARCH' situation.

...

NameDescriptionBinding
allowedonnewIf 'true', the entry is visible within the situation of type CREATE.RO*
allowedonupdateIf 'true', the entry is visible within the situation of type EDIT.RO
dataQualified name of the entry.RO
defaultrepresentationUI name of the codesystem entry. The UI representation is built using the representation pattern of the codesystem.RO
idEntry ID.RO
labelLocalized label of this entry.RO
orderIndex value of the entry within the entry list.RO
typeType of entry. Possible values are LEAFENTRY for leaf nodes and INNERENTRY for inner tree nodes.RO

*RO (ReadOnly): ReadOnly properties can only be read. Changes to value changes of RO properties do not affect the interface.

You can filter CODESYSTEM entries by providing a filter callback function. The function is called once for each entry in the given CODESYSTEM. The callback function is passed to the CODESYSTEM object by calling the 'applyFilter()' function. The entry object is passed to the callback function as an input value. The function returns 'true' if the current entry passed the filter (otherwise 'false').

...

Code Block
languagejs
linenumberstrue
scope.model.mytablefield.onrowedit = function(table, row){
	row.model.mycodesystemfield.applyFilter(function(entry){
		return entry.data === 'foo';
	}) 
};

Beginning with version 6.16 this new filter is given to disable tree entries:

Code Block
languagejs
scope.model.class.applyDisablingFilter(function(entry){
  return entry.defaultrepresentation !== 'Employee';   // entry is disabled when condition is true
}); 

...

NameDescriptionBinding
indexRow index: '-1' for newly-created row. The first row has the value '0'.RO*
copyEnabledControls whether the "Copy and create as new row" function is enabled. You can only edit this synchronously inside the onrowedit.RW**
deleteEnabledControls whether the "Delete row" feature is enabled. You can only edit this synchronously inside the onrowedit.RW
saveEnabledControls whether the "Save row" feature is enabled. You can only edit this synchronously inside the onrowedit.RW
persistedIs 'false' if the edited file was newly created. The property remains 'false' for new rows until the index data is saved. You can use this property to differentiate between a row that has been saved or newly created by the user during the current index data editing.RO
modelProvides access to the model of the current row. With this model, the script can access and modify the values and element properties of the current row.RW

*RO (ReadOnly): ReadOnly properties can only be read. Value changes of RO properties do not affect the interface.

**RW (ReadWrite): ReadWrite properties can also be written. Value changes of RW properties affect the interface.

See how the row object is used in the following example.

...

Code Block
languagejs
linenumberstrue
// see Manipulating table data
...
let tableCopy = JSON.parse(JSON.stringify(table.value)); //create a copy
for ( i = 0; i < num; i++ ) {
	if (i === 0) {
			tableCopy[i].accepted = !i%2,                               // Boolean
            tableCopy[i].created = moment().add(i+5,'day').toDate(),    // Date
            tableCopy[i].activedate = moment().add(i+5,'day').toDate(), // Another date
			tableCopy[i].author = 'Pierre Curie '+i,                    // String: Author name with i postfix
            tableCopy[i].prio = i+.00,                                  // Decimal
            tableCopy[i].company = 'OSVH'                               // Codesystem - the 'data' values must be used.
	} else {
    	// For each number add a row
	    // Each row is an object defined by the internal names of the column elements.
    	tableCopy.push({
            	accepted: i%2,                              // Boolean
	            created: moment().add(i,'day').toDate(),    // Date
            	activedate: moment().add(i,'day').toDate(), // Another date
        	    author: 'Marie Curie '+i,                   // String: Author name with i postfix
    	        prio: i+.42,                                // Decimal
	            company: 'OSVH'                             // Codesystem - the 'data' values must be used.
    	    });
	}
	// do even more fancy data manipulations
} // end for num
table.value = tableCopy;
...
// see Manipulating table data


Handling an Empty List as Erroneous (not Null)
Code Block
languagejs
linenumberstrue
scope.model.addresslist.onchange=function(){

	if(scope.model.addresslist.value.length > 0){
		scope.model.addresslist.error = null;
    } else if (scope.model.addresslist.value.length == 0) {
		scope.model.addresslist.error = {msg:'At least one address must be given.'};
	}
}

var init = function(){
	if(scope.model.addresslist.value === null || scope.model.addresslist.value.length < 1){
		scope.model.addresslist.error = {msg:'Mindestens eine Adresse muss angegeben werden.'};
	}
}

init()

...

  • qname
    The qualified name qname is not supported.

  • required
    The property required is not supported, but can be used by scripts.

  • name
    The name of the element is the technical name of the data field bound by the parameter.

  • label
    The label stems from the localized name of the data field bound by the parameter.

Mapping BPM Data Types to DMS Data Types

BPM data typeDMS data typeDescription
String + IDSTRING
BooleanBOOLEAN
Date + LocalDateDATETIMELocalDate is withtime false. LocalDate therefore stands for a day without time.

Decimal + Long

NUMBERscale is not currently supported.
CodeSystemCODESYSTEM
All list typesTABLE

Reading and Setting Feasibility of Activity Actions

...

'1' is a code which is set in yuuvis® RAD designer for each individual activity action.  

...

NameTypeDescription
idStringThe ID of the context object.
titleStringThe title of the context object.
typeNameStringThe name of the type of the context object.


Using Global Scripts

Form scripts are defined by type and situation. The scripts are independent of each other and cannot share functionality. If you need to use generally applicable functions or the project-specific logic of multiple form scripts, you can add global scripts and include them in local scripts.

Creating Global Scripts in yuuvis® RAD designer

...