The ability to save expressions and re-use them

Many of my apps use relatively complex expressions multiple times. Sometimes they start the same and end differently, but often times they’re identical and on different pages or reusable elements.

It would be amazing to be able to right-click an expression and click “Save”, give it a name, and then be able to drop it in as a variable in the middle of another expression.

Let’s say you have an expression for a search for active users. You could save this expression, then add it as a data source. Or you could modify it by further filtering the users.

In practice and implementation, this could work very similar to named ranges in Google sheets/excel.

A couple specific ideas for how to implement:

  • Saved expressions could appear as their name and a different color than the usual expression blue.
  • You could edit saved expressions and they’d update everywhere in the app dynamically. Ability to search where saved expressions are used is important too.
  • You could “detach” a saved expression from its template if you’d like to edit it. For example, you could add the “Active users” saved expression then expand/detach it and update to deactivated users for a particular search. It would no longer be tied to the saved expression, it’s just a way of saving time having to go find it and copy/paste the expression into the context you’re in.
  • Saved expressions would show up as one of the sections in the expression editor for ease of access.
1 Like

Yes, this is needed.

A good workaround is to use a reusable element (in front end) or custom event (in backend). The RE contains a custom workflow that can take parameters and return the result (trigger it by trigger custom event in a reusable element). Just place the RE on whichever page you want to use it on.

This way, if you want to change an expression, you only need to change it once in the RE/custom workflow, rather than everywhere it appears in the app.

2 Likes

Yeah, already use this workaround! Would just love to have it officially supported.