Showing results for 
Search instead for 
Did you mean: 

User-defined functions

Ability for users to create their own functions with input parameters and output properties. This would allow users to streamline their code and make their apps much easier to maintain.



  • Create new “DefineFunction” function that accepts input parameters and returns values specified by the function itself.

“DefineFunction” definition:

DefineFunction(FunctionName, [InputParameters], [OutputParameters], FunctionBody)
  • FunctionName = Name of the new Function that can be called later in the application
  • InputParameters = Comma delimited list of parameters, each parameter acts as its own self-contained context variable visible only to the function being defined
  • OutputParameters = Comma delimited list of properties that can be updated inside of the function and referenced outside of the function
  • FunctionBody = List of standard PowerApps functions delimited by semi-colons; can make use of the input parameters and return properties defined earlier
  • Additionally, all variables or collections defined within the Function would be accessible only from within the function.

Creating a function:

    [ID, RecordName],
        Patch([Items], Defaults([Items]), {

            Item_ID: ID,

            ItemName: RecordName
        Notify(“Unable to add record”, NotificationType.Error);
        Set(ReturnStatus, “Failure”),
        Notify(“Successfully added record”, NotificationType.Success);
        Set(ReturnStatus, “Success”)

Calling a custom function and accessing its return values:

        ID: 1,
        RecordName: “Hamburger”
    }).ReturnStatus = “Success”,
    Notify(“Happy Face!”, NotificationType.Success)

This is a relatively simple example but the benefits of encapsulating more complex, repeated operations in a function are pretty clear.

Status: New
Advocate IV

This would be a great idea - even if the functions so defined simply passed variable data in parameters, and returning data in return values or output parameters, this would be most helpful - for validation, generating data for presenting to the user - not repeating myself with irritating frequency would be very valuable.

Advocate IV

Great proposal - Power Apps as they become successful and potentially extended from simple data requirements, need proper maintainability (not same code repeated on different controls). So introducing multiuse functions wouldn't stop simple apps from being developed or get in the way, but would provide the future path. Critical for buy-in from both devs and customers, I would say.