Showing results for 
Search instead for 
Did you mean: 

Reusable formulas

The same way we have have reusable compnents, we should have a central place to define reusable formulas with inputs and outputs. This would allow us to make more scalable, maintainable apps by encapsulating logic and reusing it multiple times.

The cherry on the top would be to share reusable formulas accross multiple apps.

Status: New
New Member

I definitely agree! As I have been writing the same formulas on different buttons, depending on where the user activates or executes something, I always have to try and remember or comment where else in the app I need to go to make edits if there are changes.

New Member

Just started using power apps. I like it, but it seems like not having the ability to reuse formulas (sub routine) is going to be a maintenance issue the more complicated these apps get. I've thought about using Select(Control) but am regulate to controls on that screen. Thought it was might be something I just haven't figured out yet.

Impactful Individual

@DMDev there is a workaround for this with toggle buttons. 
search for reuse code an toggle button!

New Member

I'll check it out thanks...

Regular Visitor

by the way, if formulas were saved to string , I need a function to convert string to express.

Community Champion

@max81 I believe the Toggle hack may no longer work. I wouldn't recommend relying upon it.

I'm working on another technique which puts the code into a timer on a screen. Pass your input values (and a reference to a screen to navigate to afterwards) to the screen as context variables in the Navigate command. 

When the screen opens, the timer starts, runs the command (Patch or whatever) with the supplied context values, then navigates to the screen specified (or back to the calling screen).

If an output value is required you could use a global variable or write the value(s) to a collection.

Still, none of the above should be necessary - reusable blocks of code are desparately required. Now we are in the position of maintaining Apps that we (and others) have created, we are finding the difficulty in debugging and extending Apps is considerable.

Impactful Individual

@PaulD1 **bleep**. Thanks for that information. So far my apps are still running. But I haven’t republished them for a while. 

I totally agree that we need a standard function-method to reuse/call code.