New object scripts

New object scripts are run only when you create a new object, such as a new work order. These scripts are not run when you load an existing object from the database.

This script is a special type of automation script without a launch point. The name of the script must be in the format OBJECTNAME.NEW. For example, if you want to create a script that uses the purchase order (PO) object, it is called PO.NEW. You can have only one .NEW script for an object. If an object is based on a view, such as the WORKORDER table and the WOACTIVITY view, you need to create the script for each object if you want the logic to evaluate for both objects.

This type of script uses default values immediately when a record is created. Typically, you use this script when you cannot use the default value for an object inside the Database Configuration application. For example, if you want to use conditional logic, such as setting a default value when the site is BEDFORD, or when you need to retrieve information, such as from the header record.

The following script is an example of a new object script:
owner=mbo.getOwner()
if owner and owner.getName()=="PO":
    mbo.setValue("CUSTOMFIELD",owner.getString("CUSTOMFIELD"))