Best practices for reusing JS queries across apps

Goal:
I would like to reuse common JS queries across multiple applications. For example, I have a function that queries JIRA, performs some transformations, and returns a result that is then display in the UI.

I think this can be accomplished in a few different ways

  1. Create a workflow with this functionality and import it across different apps.
  2. Create a dummy module that takes intakes data, performs JS, and outputs result (Javascript Query in Query Library - #5 by ray_wu)
  3. Duplicate the code in each app

Option #1 is not very ideal, since there is some overhead in creating a workflow for a simple query. Option #2 is a bit hacky, as modules are more of a UI feature. Option #3 creates a lot of duplicated code.

Are there any better approaches on how to do this? What is the current recommended way to share JS queries that access data resources across multiple applications?

Bump - could someone take a look if possible? thanks

Hello @pablo.estrada!

It seems like you've really listed the top ways get some reusability from you code (option #3 excluded). In you post you say that you have a function that queries JIRA and then does some transformations. Is you goal to be able to "query JIRA and transform the result" from anywhere or is it preferrable/acceptable to have the JIRA query as part of your Query Library and perhaps the transformation code is accessible to call from any app instead?

I am thinking that your transformation code might need to live within your organization's preloaded Javascript (Account --> Advanced Settings):

This way you have a reusable JIRA query and the function to call to return the transformation. This, of course, has its own overhead since even apps that do not require the transformation have the function to do so loaded into them.

I think that a workflow which has the JIRA query and the transformation code to be called when necessary by an App (or other workflow) might be a better option overall, though YMMV

1 Like