Use custom function packages
Packages let you build and run your own custom logic inside Adobe Workfront Fusion, without leaving the Fusion interface. When the standard modules don’t do exactly what you need, you can use a function to transform data, do a calculation, call an external service, or wrap a routine you want to reuse. You can then test it, make it live, and use it from your scenarios.
Complex functions may require resources such as variables and dependencies such as libraries. For these functions, you can create a package that includes the function and its resources.
A package can include:
- Functions: The logic that runs during a scenario execution.
- Variables: Reusable values, such as a base URL or an API key, that the function in the package uses.
- Dependencies: Outside libraries your functions may rely on.
- History: Earlier versions of each function, saved automatically, that you can reference.
Access requirements
| table 0-row-2 1-row-2 2-row-2 layout-auto html-authored no-header | |
|---|---|
| Adobe Workfront package |
Any Adobe Workfront Workflow package and any Adobe Workfront Automation and Integration package Workfront Ultimate Workfront Prime and Select packages, with an additional purchase of Workfront Fusion. |
| Adobe Workfront licenses |
Standard Work or higher |
| Product |
|
For more detail about the information in this table, see Access requirements in documentation.
Set up the runtime environment connection
The first time your team uses this feature, you must set up the environment that runs the functions. You only do this once per team.
-
Click the Packages
tab in the left navigation panel.
If the environment has not been set up, the Runtime Environment Not Configured screen appears.
-
Click Initialize runtime.
-
To enter a name other than the default name, type the name in the Connection name field.
-
Select the Adobe App Builder project that this package will belong to::
- To select an existing project, begin typing the project name, then select it when it appears.
- To create a new project, enter a name that doesn’t already exist and click Create new.
- If you leave this empty, Fusion uses a default project.
-
Select Continue.
Fusion finishes the setup and you’re ready to create packages.
Your environment appears as a connection tab at the top of the page.
-
(Conditional) To add an additional environment, click the Plus icon and follow the instructions in this section.
-
(Conditional) To remove an existing environment, hover over the environment connection tab and click X when it appears.
note warning WARNING Removing a connection disconnects Fusion from that environment. The packages in it are no longer available in Fusion through that connection.
Create and open a package
-
Click the Packages
tab in the left navigation panel.
-
Select the tab for the connection you want to work in.
-
Click Create package.
-
Enter a name and select Create.
The package opens automatically.
-
To reopen a package later, select it from the Packages list and select View.
-
To delete a package, select it from the Packages list and choose Delete.
note warning WARNING Deleting a package permanently removes it and everything inside it.
Manage a package
An open package is organized into four areas:
- Functions: Create, test, and publish the function.
- Variables: Configure variables for the function.
- Dependencies: Install dependencies, such as outside libraries, for this function.
- History: View earlier versions of each function.
In addition to these four areas, a Storage meter at the top shows how much of your space is used. Each package has a total size limit of 21 MB. This includes functions, variables, and dependencies, including saved versions.
If you run out of space, we recommend removing unused dependencies, variables, or older versions to free some up.
To go back to the package list, select the back arrow next to the package name.
Functions
The Functions area displays a list of functions in the package, including the function’s name, its status, its size, and how many inputs it expects.
View and manage the Functions list
To filter the Functions list:
- Filter by status by clicking All, Drafts, or Published.
- Use the search bar to search for specific functions.
A function can have the status of draft or published.
- Draft: Functions in Draft status are works in progress. You can edit and test freely without affecting live data.
- Published: Published versions are live. Your scenarios run published versions of functions.
Using drafts allows you to safely make changes. You can refine a draft, test it, and then publish it when you are satisfied.
Create or edit a function in the Packages area
-
Click the Packages
tab in the left navigation panel.
-
In the Functions area, select Create function.
Or
Click the checkbox next to an existing function, and select Edit in the action bar at the bottom of the page.
-
(Conditional) If you are creating a new function, in the New function field, enter a name for the function.
-
(Optional and conditional) To rename an existing function, click the Edit icon next to the name of the function and enter the new name.
-
On the Code tab, enter the function logic.
Consider the following when creating your function:
- Functions must be written in JavaScript.
- You can read the inputs you define, reuse your variables, and call your other functions.
- As you type, suggestions appear.
-
To clean up function formatting, click Beautify.
-
(Optional) On the Parameters tab, define the inputs your function expects.
For information on inputs, see Define inputs in this article.
-
On the Test tab, test your function.
For instructions, see Test a function in this article.
-
To save this function as a draft, click Save as draft.
Or
To publish the function, click Publish.
note NOTE Publishing a function clears its version history. The published version becomes the current starting point, and earlier draft versions are no longer kept.
Define inputs
You can use the Parameters tab to describe the information your function needs each time it runs.
-
Click the Packages
tab in the left navigation panel.
-
In the Functions area, select Create function.
Or
Click the checkbox next to an existing function, and select Edit in the action bar at the bottom of the page.
-
Click the Parameters tab.
-
For each parameter you want to add, click Add Parameter and configure the following:
- Name: The name of the input
- Label: A user-friendly name shown when you test the function
- Type: The data type, such as text, number, true/false, or a structured object.
- Required: Whether a value must be provided.
These inputs become the fields you fill in when testing, and the values your scenario passes in when it runs the function.
Test a function
We recommend testing a function before publishing it.
-
Click the Packages
tab in the left navigation panel.
-
In the Functions area, select Create function.
Or
Click the checkbox next to an existing function, and select Edit in the action bar at the bottom of the page.
-
Click the Test tab.
-
Enter a value for each input.
-
Run the function:
- Select Test Draft to try your work-in-progress version.
- Select Execute Published to run the live version.
-
Review the result, including whether it succeeded, how long it took, and the output it returned.
Make changes to a live function
After a function is published, the Publish button becomes a menu:
- Republish — push your latest draft changes to the live version.
- Unpublish — take the function out of service. Your work is kept as a draft so you can come back to it.
Delete a function
- Click the Packages
tab in the left navigation panel.
- Click the checkbox next to an existing function, and select Delete in the action bar at the bottom of the page.
Variables
Variables are reusable values that your functions can use, such as a base URL, an account ID, or an API key. Storing these as variables means you set a value once and update it in one place, instead of updating it across many functions.
Create or edit a variable
-
Click the Packages
tab in the left navigation panel.
-
On the Variables tab, select New variable.
Or
Click the Edit icon next to the variable you want to edit.
-
Fill in the details:
- Key: Enter the name your functions use to refer to the value.
To rename this variable, change the Key value.
- Value: Enter the value to store.
- Type: Select whether the value type is text, a number, boolean (true/false), or a structured object.
- Description: Enter an optional note to remind you what it’s for.
- Public: Turn this option on if you want to use the variable in the scenario designer. When off, the variable is only available inside the package’s functions.
- Secret: Turn this option on to hide sensitive values, such as keys. The value is hidden in the variables list, and is also is sanitized so it isn’t exposed in the scenario designer. Your functions still receive the real value when they run.
-
Select Create variable or Save changes.
Delete a variable
- Click the Packages
tab in the left navigation panel.
- On the Variables tab, click the Delete icon next to the variable you want to delete.
Dependencies
Some functions require extra libraries to do their job. The Dependencies tab is where you add and manage those libraries.
Add libraries
-
Click the Packages
tab in the left navigation panel.
-
On the Dependencies tab, enter one or more library names, separated by commas. You can request a specific version by adding it after the name (for example,
axios, lodash@4.17.21). -
Click Install.
Remove a library
- Click the Packages
tab in the left navigation panel.
- On the Dependencies tab, click the Delete icon next to the library you want to remove.
History
Every time you save a draft of a function, Fusion keeps a copy. The History tab lets you view and restore earlier versions.
-
Click the Packages
tab in the left navigation panel.
-
On the History tab, select a function on the left to see its saved versions, newest first.
-
Select a version to view exactly what it contained at that time.
-
To restore a version, click Restore as draft.
The version is restored as a new draft, so you can review and test it before publishing. Your live version stays in place until you publish.
-
To delete a version, select the version, Click Delete version and confirm.
- Publishing a function clears its history. History tracks the changes you make while working on a draft, up until you publish.
- Deleting a version can’t be undone.
Use a package in a scenario
The purpose of building functions and variables is to put them to work in your scenarios. To use functions and variables, use the Adobe App Builder connector.
- Use function from package: This module runs one of your functions as a step in a scenario. Choose the package and function, fill in the inputs you defined, and the function’s result is passed along to the modules that follow.
- Use variable from package: This module brings one of your package variables into a scenario so you can map its value into other modules.
For information and instructions, see Adobe App Builder modules.