Using shared functions

Shared functions are custom Python functions you create one time and reuse across an organization. Instead of duplicating code in every custom function field or deployment integration, import a shared function from the function library wherever you need it.

The function library is accessible wherever you create custom functions, including:

Users with developer permissions or higher in any workspace can create and update shared functions.

Creating shared functions

Create shared functions in the function library.

Follow these best practices when creating shared functions.

  • Use descriptive names — Choose names that clearly indicate purpose, such as format_date or validate_postal_code.

  • Document with descriptions — Add descriptions to help team members understand when and how to use each function.

  • Test before publishing — Use test values to verify functionality before publishing.

  • Version carefully — Test new versions thoroughly before switching existing fields or integrations to use them.

  • Organize by purpose — Create functions for common operations like date formatting, data validation, or API calls.

  1. In Workspaces, click Function Library > Create.

  2. Specify function details:

    • Name — Enter a unique, descriptive name.

    • Description — Describe what the function does to help other users understand its purpose.

    • Arguments — Click Add argument to specify parameters. Enter argument names separated by commas.

    • Code — Write the Python function code. The function must accept the specified arguments and return a value.

    • Test values — Specify test values for each argument to validate the function before publishing.

  3. Click Run code to test with your test values.

  4. Click Publish function to save to the function library.

Updating shared functions

Shared functions are versioned: every change is saved as a new version. Custom function fields and deployment integrations that reference a function don’t automatically update to the latest published version; you update versions where they’re used.

  1. In Workspaces, click Function Library. Select and open the function to edit.

  2. Make your changes to the code, arguments, or other properties. Click Run code to test your changes.

  3. When finished editing, click Publish function.

  4. Select whether the change is a patch, minor, or major update, then click Add version.

Using shared functions in projects

After you create a shared function, you can import it anywhere you create custom functions in the project, including custom function fields and cross-class custom function fields. For example, to import a shared function in a custom function field:

  1. In a project, create or edit a custom function field.

  2. In the custom function editor, click Show function library.

  3. Select the function and click Import function.

  4. Call the function directly with the appropriate arguments. The function code isn’t added to the field editor. If you need to modify the code, copy and paste it without importing it.

In a custom function field editor, expand Imported shared functions to view all imported functions. From here, you can view function details and metadata, change versions, or remove functions from the field.

Updating the shared function version in projects

After you update a shared function, you can update projects that reference it. When you update the version for one custom function field in a project, the version is updated across all other usages of that shared function in the project.

  1. In a project, open the custom function editor for any custom function field, splitting function, or classification function that uses the shared function.

  2. Expand the Imported shared functions panel and find the function to update.

  3. Click the overflow icon Icon with three stacked vertical dots. and select Change version.

  4. Select a function version, then click Update version.

Using shared functions in deployment integrations

Shared functions are also supported in deployment integration functions.

  1. Open the deployment where you want to use the integration, and select the Configuration tab.

  2. Under Integrations, click + Add downstream integration > Custom function.

  3. Click Import function. Locate the function to import, then click Import.

  4. Call the imported function from your integration code with the appropriate arguments.

  5. Click Save.

Expand Imported shared functions to view imported functions, change versions, or remove functions from the integration.

Updating the shared function version in deployments

After you update a shared function version, you must manually update any deployments using the previous version in a downstream integration.

  1. Open the deployment where you want to use the integration, and select the Configuration tab.

  2. Under Integrations, select the overflow icon of the integration to edit, then select Edit.

  3. Expand Imported shared functions, then click the name of the function to update.

  4. Click Change version, select a function version, then click Update version to confirm.

  5. Click Save.