Share

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:

  1. Write and save the Library script in the Script Editor, selecting Library as the Script Type.

    Select library type

  2. Open or create a target script in the Script Editor (see Writing Scripts).

    Import library start

  3. In the Script Editor, click the Add Script button next to Imports.

    Import library select

  4. 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'), where workspaceID is the ID of the workspace and propertiesArray 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.

    import library

    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.

  5. 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. import library code

  6. When you are done writing the code, click Save and Close.

Was this information helpful?