Register scripts

How to register scripts in Vertec

Scripts in vertec can be registered as module menu items, as event scripts or event scripts as modules.

This article is about registering scripts as menu items. Register Scripts on events or Scripts as modules can be found in the separate articles.

Administrator Rights rights are required to register scripts.

Register script as menu item

Under Settings > Reports & Scripts, right-click Scripts and select Neu > Scripteintrag.

Activate the checkbox In Vertec Menüs anzeigen:

Vertec versions before 6.7.0.12 do not have this checkbox yet. In this case, just read on.  

designation

Under this name, the script will appear later in the Actions menu, so make sure that the name is meaningful, but not too long.

Platform

Here you can specify which (code) language the script is in:

  • Python: This is the default and preset for new script entries. Python Scripts are cloud ready and can also be executed in the Cloud App and the Web App. As of Vertec 6.7.0.12 only Python scripts can be registered as menu items.
  • VBScript: This setting is available for backward compatibility. Vbscripts in vertec can only run in the desktop Desktop App or in non-restricted mode (on-premises). On-Premises should no longer be used.

In Vertec versions before 6.6, this field does not yet exist. In this case, the script text must start with a # if it is a Python script.

Classes

Specify here the type of objects (classes) for which the script can be executed in Vertec. The menu item appears in the Actions menu (or in the context menu) only where it was registered for. If a class is not present in the selection, it can also be typed into the field by hand. Note that class names must be capitalized.

 Versions before 6.7.0.12: Valid are all in Vertec Entry inheriting from the class Classes. Script cannot be registered to containers (folders).

Versions from 6.7.0.12 for scripts of a new type (see section ): All Classes in Vertec that inherit entry from the class are valid. Script can also be registered on containers (folders, Expression folders, link containers, etc.).

Display condition

Here you can specify a display condition as an OCL expression, with which you can control whether the script appears in the Actions menu (or in the context menu) or not. Click on the button with the three dots opens the Expression Editor. The result of this expression must return a Boolean Yes/No value. Only if the condition is met will the script appear in the Actions menu.

Versions before 6.7.0.12

The condition applies only to scripts on individual objects. Script configured to display on lists does not evaluate the condition. The OCL expression refers to the argobject. Example:

  • verrechnet for a script that should only appear on invoices that have already been charged.
Versions from 6.7.0.12

For scripts of the new type (see section Changes since vertec version 6.7.0.12), the display condition refers to the list of selected objects (selectedobjects) In the OCL expression Editor, self of this list. Examples:

  • self->size = 1 for scripts that should behave as previously scripts on individual objects. Appear only if exactly one object is selected.
  • self.oclAsType(Rechnung)->select(not verrechnet)->size = 0 for an invoice script that should only appear when all selected invoices have already been charged.
  • self->first.objid = xxxx for container scripts that should only be shown on a specific folder. Alternatively also possible with Entry id.
  • self->collect(oclType.asstring)->asSet->size = 1 for a script to appear only if all selected objects have the same type.
Applicable to individual objects

Vertec versions before 6.7.0.12. Check this box if the script can be applied to the individual object (e.g. on an invoice).

For scripts registered before 6.7.0.12, this checkbox will be on the More Info page after updating to 6.7.0.12. See

Applicable to lists (containers)

Vertec versions before 6.7.0.12. Check this box if the script can be applied to a list of objects (e.g. to a project list).

For scripts registered before 6.7.0.12, this checkbox will be on the More Info page after updating to 6.7.0.12. See Changes since vertec version 6.7.0.12

Extended user rights

If registered scripts should later be able to be executed by users with restricted user rights, extended user rights can be accepted for the corresponding code locations. See the article Extended user rights in scripts.

Script Text

This is where the script code is inserted. See Code in scripts as menu items below.

Executing...
To run the script for testing purposes, click the Run button. Make sure that the current context must be correct in order to test a script in this way. Otherwise, you must run the test on the relevant entry using the Actions menu button.
Script Editor...

Opens the script, if it is a Python script, in the Script Editor. The Script Editor is then linked to the Script. This means that if you change code in the Script Editor, the script text in the script will also change.

Run scripts via menu item

Scripts on individual objects

Scripts on individual objects can be done either via the Actions menu:

Or be executed via right-click:

Scripts on lists

Scripts on lists can be executed from the Actions menu or by right-clicking on the folder:

Execute scripts by right-clicking on selected objects  

For scripts of the new type (see section Change since Vertec version 6.7.0.12), scripts can also be executed on selected objects:

If such a script is executed like a conventional list script via the Actions menu or by right-clicking on the container (folder), all entries of the list are passed:

Code in scripts as menu items

The script code must be valid Python code (or deprecated VBScript) and the entire Vertec object model is accessible from the script.

Changes since Vertec version 6.7.0.12

The checkboxes Auf einzelne Objekte anwendbar or Auf Listen (Container) anwendbar removed from the main page of the script.

  • If one or both checkboxes are set, they will be shown on the More Info page. In this case, the previous behavior (Code before vertec 6.7.0.12) applies.
  • If none of the checkboxes are set, they disappear completely from the detail page. Instead, the checkbox is In Vertec Menüs anzeigen on the main page. In this case, the new behavior applies (Code from vertec 6.7.0.12).

Code from Vertec 6.7.0.12

The variable argobject is not available in the script. Instead, there is the variable selectedobjects. This contains the list of objects selected for the execution of the script:

  • If you use the feature by right-clicking on one or more items in the list, this is a list with the selected items as content.
    • If only one object is selected or if the script is called on a single entry, it is a list of one item.
  • If you use the feature by right-clicking on a container (folder), it is a list of container entries.
    • In this case, there is the variable currentobject, which contains the container (folder).
    • If the script is registered to a container or folder (Classes field), it is a list of the selected container(s).
for obj in selectedobjects: 
    ...

Code before Vertec 6.7.0.12

The variable argobject returns the currently current object (the current entry) in Vertec.

  • For scripts that are applicable to individual objects, this is the entry from which the script is executed.
    projekt = argobject
    • If the script is executed by right-clicking on a single entry in a list, the variable currentobject, which contains the parent container (folder).
  • In the case of scripts that are applicable to lists (containers), it contains the container on which the script is executed. The entries in the list are argobject.eintraege callable.
    projektlist = argobject.eintraege
    for projekt in projektlist:
        ...

 

 

 

Netherlands

United Kingdom