---
schema_version: "1"
id: a4762dac43b680bef569ace38ae473eead00b51b93a01a0c8fc6bc0ba21eba64
title: Workflow for Creating Custom Functions (Managed Package)
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/xcloud/264-0-0/os_workflow_for_creating_custom_functions.md
canonical_url: https://help.salesforce.com/s/articleView?id=xcloud.os_workflow_for_creating_custom_functions.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 0cd4a94caff423723172496e427561744ba1a3d704aba75eb8f8d9f85c554124
description: For the managed package runtime, you can add custom functions for use in formulas using Apex.
products:
  - Omnistudio
release: "264"
---
# Workflow for Creating Custom Functions (Managed Package)

For the managed package runtime, you can add custom functions for use in formulas using Apex.

![Managed Package app icon](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio_for_managed_packages-264-0-0-production-enus/aa2554ec-624a-4ee6-8da4-6435670e6e62/resources-global/_corporate/images/managedpackageicon.png) This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see [Omnistudio Help](https://help.salesforce.com/s/articleView?id=xcloud.os_omnistudio_standard.htm&language=en_US).

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio_for_managed_packages-264-0-0-production-enus/aa2554ec-624a-4ee6-8da4-6435670e6e62/images/icon_note.png)

Note

In Vlocity Health and Insurance Spring '21 and later releases, you can use the FUNCTION function instead.

1. Create the Apex Code for the Custom Function.
2. Define the Metadata for the Custom Function.
3. Handle any `LIST` input.
4. Test the Custom Function.

- **[Create the Apex Code for the Custom Function (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_create_the_apex_code_for_the_custom_function.htm&release=264.0.0&type=5)**  
    For the managed package runtime, to implement a custom function, define an Apex class and add a method to the class that contains the function logic.
- **[Sample Apex Code for a Custom Function in Omnistudio for Managed Packages (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_sample_apex_code_for_a_custom_function_in_vlocity.htm&release=264.0.0&type=5)**  
    For the managed package runtime, an Apex class implements methods for three custom functions in Omnistudio for Managed Packages. Integration Procedures and Omnistudio Data Mappers can use these functions to convert a list to an array, replace one character with another, or reformat phone numbers. The class and `invokeMethod` of custom functions must be global.
- **[Define the Metadata for the Custom Function (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_define_the_metadata_for_the_custom_function.htm&release=264.0.0&type=5)**  
    For the managed package runtime, you must define the metadata required for a custom function in Salesforce.
- **[List Input in Custom Functions (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_list_input_in_custom_functions.htm&release=264.0.0&type=5)**  
    For the managed package runtime, if an input to your custom function is of the type `List<Object>`, the input is saved to a `VLOCITY-FORMULA-LIST` key. To retrieve the input, use code that retrieves this key.
- **[Test the Custom Function (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_test_the_custom_function.htm&release=264.0.0&type=5)**  
    For the managed package runtime, to verify that you have configured the custom function correctly, go to the Omnistudio Data Mapper Designer Formula tab, add a formula, and type the first letter of the function name. The list of available functions is displayed, and if your configuration is correct, your function is listed.