Scripting Basics
Learn about script types and triggers, access to item fields, permissions and security considerations, and more.
Script Types and Triggers
The item Object and Access to Item Fields
The scripting engine automatically loads the associated workspace item into the item
object. Follow these guidelines to access item field values through the object:
Item Detail Fields. Implemented as properties on the
item
object. The name of a property must be set to the ID assigned to the field when configured. For example, a Detailed Notes field with the IDDETAILED.NOTES
is represented asitem.DETAILED.NOTES
.Important:Configured workspace item fields are referenced by Field ID. Field IDs are always in upper case.
Multi Select Fields. Implemented as a standard JavaScript object array. Use of the
indexOf
function is supported to determine if an array contains a specific item.Warning:Because of likely unstable behavior, we strongly discourage you from using the
typeOf
JavaScript keyword.Picklist Values. Represented as the actual value entered when the list is created.
In a previous release, the scripting engine required the use of the loadItem(dmsID)
function to load the item
object. For backwards compatibility, the engine continues to support the function. However, the function is deprecated, and we recommend that you do not use it going forward.
Access to linked item data
Because a property on the item
object can represent another workspace as well as an item field, scripts can access data in linked items, as shown in this example:
if item.MANUFACTURING_PLAN.STATUS == 'Complete'
returnValue(true);
else
returnValue(false);
Here, the MANUFACTURING_PLAN
property is a field of the workspace item that is actually a link to an item in another workspace (for example, "Manufacturing Plan"), and the STATUS
property is a lookup field of the linked item.
Return Value Requirement
All Condition and Validation scripts must return a value and can use the returnValue()
function to do so. The value returned by a script is evaluated to determine whether the precondition is met (true/false) or the validation is successful (pass/fail).
Note If
returnValue()
is called multiple times in a script, the value of the last call is the "winner."
Example:
if (item.STATUS == 'OPEN' || item.STATUS == "PENDING')
returnValue(true);
else
returnValue(false);
For backwards compatibility, the scripting engine continues to support returning a value with the "return value" as the last statement in the script.
Permissions and Security Considerations
Permissions
Scripting is part of the Setup Administration permission. A typical setup to grant the permission to a user is as follows:
- Add the Setup Administration permission to an Administrator role.
- Associate the Administration role with an Administrator group.
- Add the user to the Administrator group.
Security considerations
Scripting is an advanced feature of Fusion Manage. We recommend that you limit the feature to Administrators with some background in programming.
The scripting engine does NOT honor the Fusion Manage permissions assigned to the current user. To control scripting permissions, use Security functions.