You can create a user-defined script that performs any task you wish. These are often called from the output expression of a field or from another script.

How you call a user-defined script and what is passed to it depends on the script language you use. See the Script Languages topic for details.

If your script retrieves additional data from the database, here's a blog post about how to improve performance and handle multi-database reports.