Page Properties | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||
Ressourcesyuuvis® RAD - Client-side Form Scripting (parts will be taken over and be available with the next version 2.3 RemarksMartin B. is working on it together with Manuel and Stevan ... |
...
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'
Name | Description |
---|---|
api | Supplies 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. |
data | Supplies all object fields defined in the object or process activity. The fields offer read-only access using the technical name. Available for releases 2017-09-27 (3.22.x) or later. |
model | Supplies 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). |
objectId | Supplies the ID of the current DMS object if available (available since version 6.4). |
...
General object field properties
The following table describes object field properties that can be accessed with 'scope.model'.
Column "Binding"
- RO (ReadOnly): ReadOnly properties can only be read. Changes to the values of RO properties do not affect the interface.
- RW (ReadWrite): ReadWrite properties can also be written. Changes to the values of RW properties affect the interface.
Each field has the following properties:
Name | Description | Binding |
---|---|---|
name | The normalized name of the fields. Normalized means the simple field name is lower case. The name must not contain special characters except one ':'. This name is used to map the fields to the 'model.' | RO* |
label | The display name of the type in the current user locale. Used as a field identifier. | RO |
description | A field description. Can be used in tooltips for example. | RO |
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 |
readonly | If the read-only property is set to 'true,' the user cannot change the field value. | RW** |
required | Flags a field as mandatory. If this property is set, the user must make an entry. | RW |
value | The current value of the field. | RW |
cardinality | In case of 'multi' instead of 'single' (equal 'undefined') a list 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.
...
Name | Description | JavaScript data type | Multi-selection |
---|---|---|---|
STRING | Any text. See also datatype: STRING. | String | Yes |
NUMBER | Number and floating point number. See also datatype: NUMBER. | Number | Yes |
BOOLEAN | Simple 'on/off' or 'true/false' value. | Boolean | No |
DATETIME | A date or a date with time value. | Date | Yes |
ORGANIZATION | A string field for saving user IDs. The title of the user is shown, or the ID if no title exists. | String | Yes |
ID | A string field for saving object IDs. The IDs can be restricted to the specified object types defined in the classification - tag 'id:reference[object type 1, object type 2, ...]. The title of the object is shown, or the ID if no title exists, or '!******' if the object can't cannot be accessed. | String | Yes |
CATALOG | A string field for saving elements of a given array in the classification - tag 'catalog[value1, value2, ...]' | String | Yes |
TABLE | A table with columns of the above datatypesdata types | Table | No |
STRING
For fields of type 'string' the following properties are given:
Name | Description | Binding |
---|---|---|
maxlen | The maximum number of characters permitted as a value in this field. | RO |
minlen | The minimum number of characters permitted as a value in this field. | RO |
classification | If available, a specific type of text field is described.
| 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. |
NUMBERS
For fields of type integer and decimal the following properties are given:
Name | Description | Binding |
---|---|---|
maxvalue | The maximum number permitted as a value in this field. | RO |
minvalue | The minimum number permitted as a value in this field. | RO |
classification | If 'digital' is set the numbers are formatted with a thousand separator, e.g. for Din EN 1,569,345.43 and DE 1.569.345,43 | 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. |
DATE
Sample Script: Specifying a date in the future
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
/** * Example script: Manipulating table data based on index data change. */ // Add change listener to field 'myTenant:number' scope.model.['myTenant:number'].onchange=function() { // The current user input on field with the internal name 'myTenant:number' var num = scope.model.['myTenant:number'].value; // Shortcut to access the table var table = scope.model.['myTenant:changes']; if(num>0 ) { // If 'myTenant:number' is set (greater than 0) we automatically fill the table if( !table.readonly ) { // The user may not modify the table table.readonly=true } } else { // If 'myTenant:number' is not set (less than 0) we let the user fill the table if( table.readonly ) { // The user may modify the table table.readonly=false } } // automatically fills the table if 'myTenant:number' is greater than 0 // and add num rows to the table if(num>0) { // Clean up the table by setting a empty array table.value.length=0; // changes of a single cell must be done in an array variable first, // and then this array has to be pushed back to the table. for( i=0; i<num; i++ ) { // For each 'myTenant:number' add a row // Each row is an object defined by the internal names of the column elements. table.value.push( { 'myTenant:accepted': i%2, // Boolean 'myTenant:created': new Date() , // Date 'myTenant:activedate': new Date(), // Another date 'myTenant:author': 'Marie Curie '+i, // String: Author name with i postfix 'myTenant:prio': i+.42, // Decimal 'myTenant:company' : 'OSVH' // Codesystem - the 'data' values must be used. } ) } // end for num } // end if num>0 } |
Callback for
...
tables
Name | Description |
---|---|
onrowedit | This callback is called when the user starts to edit a table row. Like 'onchange,' the first parameter contains the field element (the table itself). The second parameter contains a 'row' object, which describes the row the user wants to edit. |
...
Name | Description | Binding |
---|---|---|
index | Row index: '-1' for newly - created rowrows. The first row has the value '0'. | RO* |
copyEnabled | Controls whether the "Copy and create as new row" function is enabled. You can only edit this synchronously inside the onrowedit. | RW** |
deleteEnabled | Controls whether the "Delete row" feature is enabled. You can only edit this synchronously inside the onrowedit. | RW |
saveEnabled | Controls whether the "Save row" feature is enabled. You can only edit this synchronously inside the onrowedit. | RW |
persisted | Is '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 |
model | Provides 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.
...
If we deal with more complex table value manipulation, we need to create a copy of the values. Once the values are written, the table gets is populated and changes will get be lost. Once all the cell manipulations are done, we can assign the manipulated values to the table values.
...
Please refer to the Client Plugin API documentation for more features you may use for specific requirements like notifying the userusers, getting information about the current user, or calling other services via http.