Using scripts on events
Product line
Standard
|Expert
Operating mode
CLOUD ABO
|ON-PREMISES
Modules
Services & CRM
Budget & Phases
Purchases
Resource Planning
Business Intelligence
Scripts can be started by certain changes, so-called events. As soon as such a change occurs, the stored script runs automatically, without additional user interaction.
An event script is created like a normal script via Settings > Reports & Scripts > Script: Right-click New > Script.
designation |
Any designation can be entered here. Event scripts do not appear in a menu. |
|||||||||||||||
Platform |
From version 6.6. This field is used to indicate whether it is a Python Script or VBScript When executing the scripts, a distinction is made according to the platform setting whether VB or Python is executed. |
|||||||||||||||
Classes |
Nothing can be entered here for event scripts, otherwise the event script would appear in the corresponding menu, which is undesirable. |
|||||||||||||||
Condition |
This field has no relevance for event scripts. It only controls the visibility of normal scripts in the menu. |
|||||||||||||||
Applicable to individual objects / Applicable to lists (containers) |
Not required for event scripts. | |||||||||||||||
Event script for |
Scripts can be registered on the following types of events:
|
|||||||||||||||
Classes |
Specifies which classes the script responds to. No class is required for event scripts of the type Login. |
|||||||||||||||
Fields |
Here you can specify a single field on the class, whose change you want to react to. Specify a field is only useful for event scripts of the type Modified. If you want to respond to more than one field, you can specify them one after the other, separated by commas. You can also specify custom field items by simply specifying the name of the custom field item. If no field is specified, the script responds to all fields, i.e. to all changes made to that class. This should not be done under any circumstances, as this can result in massive performance loss. event scripts cannot be registered on derived attributes (calculated fields).
|
|||||||||||||||
Extended user rights |
A Script can be Extended user rights be accepted. |
An event script should know which event triggered it on which member. This makes it easier to handle different events with the same script. The global variable args is available for this purpose:
Example:
if args.eventmember == 'active’: argobject.note = 'Active has been changed’ if args.eventmember == 'project leader’: argobject.note = 'PL has been changed’
If dialogs are displayed shown in an event script, it must always be queried whether the client is capable of showing user-specific dialogs, i.e. whether the client is one of the full-featured apps.
This is done by means of: OCL operator
.hasGui, which True
or False
returns.
It is important that no dialogs are shown if this is not possible on the client being used, as this may block Vertec or lead to undesirable results: msgbox()
for example, gives OK
back if the dialog cannot be shown. If it also had a cancel button and the code assumes that a user is active OK
has clicked, data may be changed, deleted, etc., unintentionally.
When using scripts on events, note the following:
For these reasons, it is possible to start Vertec with a /noevents parameter. This prevents any event scripts from being executed in Vertec.
To temporarily prevent the execution of event scripts within other scripts, there is the method vtcapp.DisabledEvents() .