Repository navigation
Scripts (EN)
Control Panel › Script manager – small Groovy scripts for a kind of record (invoices, offers, contacts, products, …) and a group.
| Name ("Use as") | When | What it can do |
|---|---|---|
any name, e.g. greeting
|
when exporting with a template | its result is the template field <item.property.greeting> (documents; <contact.property.greeting> for contacts, <product.property.greeting> for products) – the data is not changed |
modifyOnSave |
before a record is saved | change the data, e.g. clean up a text |
executeAfterSave |
after saving | e.g. a notice, another record |
executeAfterCreate |
after a record is created | e.g. defaults |
modifyOnDelete |
before deleting | throw an exception to stop the deletion |
IntItemLabel |
when a document is shown | its result is the name of documents in lists |
IntRevenueLabel |
when a revenue is shown | its result is the name of revenues in lists |
Choose the purpose with Use as; a line below the name says what the name does.
dbo |
the record (e.g. the invoice) |
getObject('contact', 'Smith') |
another record by kind and name |
getFormField('item.netvaluef') |
a template field of the record |
The last value is the result. Scripts may span several lines.
Template field greeting for invoices:
def name = getFormField('item.contact.cname')
name ? "Dear ${getFormField('item.contact.prename')} ${name}" : "Dear Sir or Madam"In the template: <item.property.greeting>.
The Properties table of a single record (documents, contacts) gives the same kind of field without a script: name delivery, value 2 weeks → <item.property.delivery>; a contact's property in its documents: <item.contact.property.NAME>.
modifyOnSave for products – no spaces around the name:
dbo.setCname(dbo.__getCname().trim())Write the script, then Test with a record… – it runs on a record you choose and shows the result.
Toolbar actions… (button in the script manager; was View › Add toolbar action): own buttons in a toolbar that run a Groovy script. In these scripts: MPView (the main window), Application, QueryHandler. Takes effect after a restart.
Deutsch: Skripte
![]()