http://powerappsguide.com/blog/post/how-to-create-user-defined-functions
https://pnp.github.io/powerplatform-samples/
https://github.com/pnp/powerfx-samples/tree/main/samples
Format Currency for labels.
-
- Create a new Component
- Add a function “functionFiscalYear “to the Component crated
- set the function property type as output, set the data type that returns as string,
- Add a new property to the function “paramDate”, data type: Date and Time, required hit Create
- Where to add the code, click on the function name and in the left properties box you can see the name of the function and the property that the function can use, stay on the function name line.
- Add Your code.
[code]
// fiscal year starts at October 1st 10/01/2021
// 09/30/2021 is fiscal year 2021
// 10/01/2021 is fiscal year 2022
// so if month is => 10 then add 1 to the year.
If(
Month(paramDate) >= 10,
Year(paramDate) + 1,
Year(paramDate)
)
[/code] - How to use it:
Got to a screen and add the new component created, minimize it. Add a date picker and a text input
- on the text input Default property call in the ComponentName.FunctionName(and pass the parammeter)
Now you can use the same function in many places, but the code you can fix or change only once. - Limitations: we cannot access data sources or objects from the host screen or app
- How to download and use existing UDFs
Go to: https://github.com/pnp/powerfx-samples/tree/main/samples
Click on Date Functions
Scroll down to “Minimal Path to Awesome”, click on the Download, save the .msapp on your computer,
- Create a new Canvas app
- Click on File
- Open
- Browse to the location where you downloaded the .msapp file, click on the file it will create a new canvas app, we to save it.
- Share it with the team:
- Create a new Component