Importing Library Scripts
The Fusion Manage scripting engine supports Library scripts containing functions that can be used in Action, Condition, and Validation scripts.
When you save a script as a Library script, it can be imported into other scripts so its function can be called from a target script as needed. You can import multiple Library scripts into a single script, and the same Library script can be imported into multiple scripts.
To import and use a Library script:
Write and save the Library script in the Script Editor, selecting Library as the Script Type.
Open or create a target script in the Script Editor (see Writing Scripts).
In the Script Editor, click the Add Script button next to Imports.
In the drop-down list, click the name of the Library script you want to import.
Best PracticeSelect createNewItem to import a script containing a function to create a new item in a given workspace. The function uses
createItem('WS_WORKSPACE_ID')
, whereworkspaceID
is the ID of the workspace andpropertiesArray
is an array of the item field values you want to set.function createNewItem(workspaceID, propertiesArray){ newItem = createItem(workspaceID); for(var propKey in propertiesArray){ newItem[propKey] = propertiesArray[propKey]; } }
A button for the selected script appears next to Imports.
Tip:To remove a selected script from Imports, click the Delete icon on the script button. You can import more than one Library script into a target script. To import more scripts, repeat steps 3 and 4 until all the scripts are imported.
In the Code text box, write the target script, calling the function in the Library script as needed.
Best PracticeCall
createNewItem
(see step 4) to create a new item in a Customers workspace (WS_CUSTOMERS) and set values for NAME and EMAIL fields.When you are done writing the code, click Save and Close.