Global Scripts for Forms

yuuvis® RAD designer 9.x »

Form scripts are integrated for each object type and form. The scripts are independent of each other and cannot share functionality. If generally applicable functions or project-specific logic of several form scripts are to be used, global scripts can be saved and integrated into form scripts.

The Manage scripts functional right is required.

Global scripts are created in the Scripts area in yuuvis® RAD designer.

Global scripts get a unique technical name as a property and a description, which is optional.

A global script can define which functions or values are publicly available. The result returns a JavaScript object named 'exports'.

Global sample script:

return {
    exports : {
        markRequired: function(element) { element.required=true; }
    }
}

This script provides a function that marks a single element as a mandatory field. Only functions defined in 'exports' are available to other scripts. This script can be saved under the technical name 'FormUtils', for example.

If a global script provides many functions, it is recommended that the declaration of the functions and the implementation are kept separate.
Example:

return {
	exports : {
		markRequired: markAsRequired;
	}
function markAsRequired(element) { element.required=true; }

Here the markAsRequired function is exported under the name markRequired.

Global Scripts in Form Scripts

Global scripts have a unique technical name in the system. A form script, which draws on the functions of the global 'FormUtils' script, can be formulated as follows:

return {
    uses : ['FormUtils'],
    init: function(util) {
        util.markRequired(scope.model.vorname);
    }
}

The 'uses' section of this form script defines which global scripts will be used. The technical name of the global script is specified. If several global scripts are to be used, a list of scripts can be specified as a string array. The exports of the global script are handed over to the init function as transfer parameters as defined by the script and can be used there. This sample script causes the 'firstname' field to be marked as a mandatory field.

In this simple case, the same can be achieved using the following form script: scope.model.vorname.required=true;