Register scripts

How to register scripts in Vertec

Product line

Standard

|

Expert

Operating mode

CLOUD ABO

|

ON-PREMISES

Modules

Services & CRM

Budget & Phases

Purchases

Resource Planning

Business Intelligence

Created: 26.06.2003
Machine translated
Updated: 19.08.2024 | Article renewed and adapted to version 6.7.0.12

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

This article is about registering scripts as menu items. You can find out how to register Scripts on events or Scripts as modules in the separate articles.

You need Administrator Rights to register scripts.

Register script as menu item

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

Activate the checkbox In Vertec Menüs anzeigen:

In Vertec versions before 6.7.0.12, this checkbox is not yet available. 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:

  • Python: This is the default and default 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 reasons. Vbscripts in vertec are only executable in the desktop app (on-premises) and not cloud-ready. We therefore recommend using only Python scripts.

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

Classes

Specify here for which type of objects (classes) 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 does not exist 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 that inherit from the class Classes . Scripts cannot be registered on containers (folders).

Versions from 6.7.0.12 on scripts of the new type (see section ): All Classes in Vertec that inherit from the class entry are valid. Scripts 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. Clicking on the button with the three dots opens the Expression Editor. The result of this expression must return a Yes/No value (Boolean). 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. Scripts configured to display on lists will 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 from 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 in the same way as scripts on individual objects used to. So only appear when only 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 when 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. to an invoice).

For scripts registered before 6.7.0.12, this checkbox can be found on the More Info page after the update to 6.7.0.12. See section

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. a project list).

For scripts registered before 6.7.0.12, this checkbox can be found on the More Info page after the update to 6.7.0.12. See section Changes from 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, an extended permission can be accepted for the corresponding code points. See the article Extended user rights in scripts .

Script text

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

Execute...
To run the script for testing purposes, click the Run button. Make sure that the up-to-date context is correct to test a script. Otherwise, you have to 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 entry. This means that if code is modified in the Script Editor, the script text in the script entry also changes.

Execute scripts via menu item

Scripts on individual objects

Scripts on individual objects can either use the Actions menu:

Or by right-clicking:

Scripts on lists

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

Run scripts by right-clicking on selected objects  

For scripts of the new type (see section Changes from 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 obsolete VBScript). The entire Vertec object model is accessible from the script.

Changes from Vertec version 6.7.0.12

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

  • If one or both checkboxes are set, they are 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 shown on the main page. In this case, the new behavior takes effect (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 objects 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 (field Classes ), 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 up-to-date object (the up-to-date 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, there is also the variable currentobject which contains the parent container (folder).
  • For 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:
        ...