Basics of building Power Fx functions
Building functions in Dataverse is easier now because of low-code Power Fx and an intuitive interface. Functions are reusable solution objects that run logic server-side in Dataverse, making them powerful tools for streamlining your apps. You can call functions from canvas apps, model-driven apps, custom pages, flows, and more.
If you're new to Power Fx functions, the following sections go through the key factors to consider when creating one.
Key properties of a Power Fx function
The key properties of a Power Fx function are:
Display name (required) - The user-friendly name of your function. Using clear, meaningful names helps when you're managing multiple functions. Consider a consistent naming convention to keep organized. Keep in mind that after you create the function, you can't change the name.
Schema name - The system's logical name for the function. The system automatically generates the schema name when you enter a display name, and like the display name, you can't change it later.
Description (required) - A short explanation of what your function does. Adding a clear description helps others (and you) understand its purpose. Similar to the name, you can't edit this property after creation.
Formula (required) - Where you enter your Power Fx expression to perform actions or calculations. As you write, IntelliSense helps flag issues. A red underline means that an error is in your formula. You can hover your cursor over the underlined part and IntelliSense can tell you what the problem is.
Table references (optional) - You can link your function to up to five Dataverse tables, which allows you to pull data by using Filter() or LookUp(). Remember, functions run in the context of the user, so make sure that the referenced tables are accessible to users who are calling the function. Functions can't override Dataverse security.
Parameters (optional) - Functions can take input parameters (to send data to the function) and output parameters (to return results). These parameters work similarly to variables in that they accept dynamic input, which helps make your functions flexible and reusable across different apps.
Supported parameter types
Your function can accept and return these data types:
- Boolean
- String
- Float
- Decimal
- DateTime
- Integer
Keep in mind
Keep the following aspects in mind when working with Power Fx functions:
- Some Power Fx formulas have limitations or aren't supported in Dataverse functions. Before starting, check the list of supported functions to avoid surprises.
- You can store functions in Dataverse solutions, which makes them portable across environments. If you're working in a managed solution, you might have restrictions on modifying or deleting existing functions.
- If your function depends on other Dataverse tables or functions, be mindful of dependencies, especially when you're moving solutions between environments.
- Keep track of where people use your function (such as in apps or flows) to avoid breaking dependencies when you later modify it.
- Versioning functions aren't automatic, so consider maintaining documentation if you make updates.
- Don't delete your functions from the Solutions area because it might leave behind orphan components. Instead, you should delete functions from the Functions area in Power Apps. Select the function that you want to delete and then select Delete on the command bar.
With these basics, you're ready to start creating your own Power Fx functions. Enjoy the building process, and don't forget to explore and experiment.