User-defined functions
Overview
The user-defined functions feature in Sift makes it easy to create reusable logic for your expressions across Rules and calculated Channels. Expressions in Sift are written using functions, and now these can also include user-defined functions that you or your team can define using CEL (Common Expression Language).
By capturing common calculations as user-defined functions, you can improve the readability, maintainability, and consistency of your expressions. This makes it easier for teams to share best practices and reduces the risk of errors from duplicated or inconsistent logic. User-defined functions provide version control to ensure your expressions remain reliable as they evolve and support robust analysis across your workspace.
Instructions
Create a user-defined function
To create a user-defined function, consider the following steps:
- In Sift, click .
- In the Sift navigation menu, click User-defined Functions.
- Click + New Function.
- In the User-defined function name box, enter a name for the user-defined function.
Note
When creating a user-defined Function, follow the following naming requirements:
- No spaces
- The name must be 1 to 253 characters long
- Must start with a letter
- Use only letters, numbers, and underscores
- Optional: In the Description box, enter a description for the user-defined function.
- In the Number list (inside the Inout Channels box), select an input data type for the first input Channel ($1).
- To add other input Channels, consider the following steps:
- Inside the Input Channels box, click Plus.
- In the new Number list. Select an input data type for the second input Channel ($2).
- In the Enter an expression box, define the expression for the user-defined function using the previously created (defined) input Channels.
- Click Save.
Preview a user-defined function
A preview refers to applying a Run to a user-defined function in order to see how it evaluates and operates in practice. This lets you observe the user-defined function’s behavior with real inputs, helping you verify that it performs as intended before using it in production. To preview a user-defined unction, consider the following steps:
- In Sift, click .
- In the Sift navigation menu, click User-defined Functions.
- In the User-defined Functions table, click the user-defined function you want to preview.
- In the Preview box, click click Plus.
- In the Runs table, select a Run to preview the user-defined function.
- Click Next.
- In the Select Channels tab, select the Channels from the selected Run to associate with the created input Channels.
- Click Preview.
Edit a user-defined function
To edit a user-defined function, consider the following steps:
- In Sift, click .
- In the Sift navigation menu, click User-defined Functions.
- In the User-defined Functions table, click the user-defined function you want to edit.
- Click Edit.
- Edit and preview your changes.
- Click Save changes.
Note
Making and saving changes to a user-defined function creates a new version of that user-defined function. However, there are some important limitations to be aware of when editing:
- Name: The user-defined function name can only be edited if it has not yet been referenced by anything else.
- Input Channels: The Input Channels can be modified as long as they are not currently being referenced elsewhere.
Archive a user-defined function
To archive a user-defined function (which means removing it from the list of available user-defined functions when users in your organization are defining Rules or calculations on Channels), consider the following steps:
- In Sift, click .
- In the Sift navigation menu, click User-defined Functions.
- In the User-defined Functions table, click the user-defined function you want to archive.
- Click More options.
- Select Archive.
- Click Archive Function.
Unarchive a user-defined function
Anyone in the organization can unarchive a user-defined function, which makes the user-defined function available again when users are defining Rules or calculations on Channels. To unarchive a user-defined function, consider the following steps:
- In Sift, click .
- In the Sift navigation menu, click User-defined Functions.
- Click Show Archived.
- In the User-defined Functions table, click the user-defined function you want to unarchive.
- Click More options.
- Select Restore.