With the Canvas Apps, there seem to be no simple way to reuse the same “code”/”formulas” without opting for a workaround such as creating a hidden button with all the reusable code bundled into the button’s “onselect” handler. In some cases this works great, in others it can be messy.
Here is an alternative – there is “Canvas App Code Reuse” plugin for XrmToolBox:

Canvas App Code Reuse tool for XrmToolBox
The way it works is:
- Your Canvas App must be added to a CDS solution (it does not have to use CDS data source, though)
- In the Canvas App, you can use “code tags” to identify places where code replacement should happen – basically, you need to prepare the mark up for your app by adding commented blocks
//TAGNAME_START
//TAGNAME_END
- Everything between those tags will be replace with the actual value of the tag that you’ll specify in the plugin
- Once the markup is ready, make sure to save the app and publish it
In the XrmToolBox:
- Install “Canvas App Code Reuse” tool
- Connect to the environment
- Open the tool
- Select a folder for your “project”