Importing npm library to templater js file

First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.

What I’m trying to do

I’m using a templater template that makes use of some javascript to take advantage of the amazing Jira Issue plugin.

I’m now looking to add functionality to my templated that is afforded by this smartsheets javascript sdk..

Question: How do I get the javascript environment, used by templater, to recognize libraries I’ve installed via npm, WHILE ALSO maintaining access to the other plugins my script currently has access to, such ? e.g. npm install smartsheet

I’ve provided my example template, that makes use of templater laguage in combo with javascript that takes advantage of the jira-issue plugin javascript api. I have no idea where $ji is somehow magically loaded such that the templater code successfully understands I’m referencing the jira-issue plugin’s api. but that works … somehow.

Things I have tried

I’m aware of this answer. However, my use-case is slightly different.
I can’t just create a new plugin, because I need my javascript to reference multiple other already existing plugins. i.e. templater, and jira-issue.

The template code referenced above.

const user = 'myUsername';
const project = "theProject";
// call out to the jira-issue javascript api via the $ji variable. NO idea, how or why that's loaded and available here. But, awesome that it is.
const epicResponse = await $ji.base.getSearchResults(`project = ${project} AND issuetype = Epic AND issueFunction in epicsOf("assignee in (${user})") AND (resolution != Done OR resolution is EMPTY )`);
for (let epic of epicResponse.issues) {
%>
## https://jira.mycorp.com/browse/<%* tR += `${epic.key}` %>
### Description
\```
Name: <%* tR += epic.fields.summary %>

<%* tR += epic.fields.description %>
\```
<%*
 const childResponse = await $ji.base.getSearchResults(`"Epic Link" = ${epic.key} AND assignee = ${user} AND resolution = Unresolved`);
  
	  // iterate over the child issues and print their summaries and keys
	  for (let child of childResponse.issues) {
%>
### https://jira.mycorp.com/browse/<%* tR +=`${child.key}` %>
<%*
//get any subtasks
	  	
	  	const subTasks= await $ji.base.getSearchResults(`project = ${project} AND parent = ${child.key} AND assignee = ${user} AND (resolution != Done OR resolution is EMPTY )`);
	  	//check to see if any sub tasks exist to iterate over
	  	if(subTasks.issues.length!=0){
	  		
	  		//iterator over sub tasks
	  		for(let subChild of subTasks.issues){		
%>

#### https://jira.mycorp.com/browse/<%* tR += `${subChild.key}` %>

<%*	  	
	  	
	  		}
	  	
	  	
	  	} 	
	  }
	}

%>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.