Template Content
About the template
About ScriptRunner Connect
What is ScriptRunner Connect?
Can I try it out for free?
Yes. ScriptRunner Connect comes with a forever free tier.
Can I customize the integration logic?
Absolutely. The main value proposition of ScriptRunner Connect is that you'll get full access to the code that is powering the integration, which means you can make any changes to the the integration logic yourself.
Can I change the integration to communicate with additional apps?
Yes. Since ScriptRunner Connect specializes in enabling complex integrations, you can easily change the integration logic to connect to as many additional apps as you need, no limitations.
What if I don't feel comfortable making changes to the code?
First you can try out our AI assistant which can help you understand what the code does, and also help you make changes to the code. Alternatively you can hire our professionals to make the changes you need or build new integrations from scratch.
Do I have to host it myself?
No. ScriptRunner Connect is a fully managed SaaS (Software-as-a-Service) product.
What about security?
ScriptRunner Connect is ISO 27001 and SOC 2 certified. Learn more about our security.
This template creates an Excel file in memory using the write-excel-file NPM package and then uploads it as an attachment to a specified Jira Cloud issue.
ISSUE_KEY
parameter to the desired Jira issue key.Manually run the UploadExcel
script.
If successful, the newly generated Excel file will be attached to the specified Jira Cloud issue.
import JiraCloud from './api/jira/cloud';
import writeXlsxFile from 'write-excel-file';
export default async function (event: any, context: Context): Promise<void> {
const { ISSUE_KEY } = context.environment.vars as EnvVars;
// Sample data
const students: Student[] = [
{
name: 'John Smith',
dateOfBirth: new Date(),
cost: 1800,
paid: true
},
{
name: 'Alice Brown',
dateOfBirth: new Date(),
cost: 2600,
paid: false
}
];
const excelFile = (await writeXlsxFile(students, {
schema: [
{
column: 'Name',
type: String,
value: student => student.name
},
{
column: 'Date of Birth',
type: Date,
format: 'mm/dd/yyyy',
value: student => student.dateOfBirth
},
{
column: 'Cost',
type: Number,
format: '#,##0.00',
value: student => student.cost
},
{
column: 'Paid',
type: Boolean,
value: student => student.paid
}
]
})) as any as Blob; // Doing any to Blob cast because if the file name is not provided it is supposed to return a Blob, but offical types don't reflect that in reality and return void instead which needs to be overwritten
const fileName = `students-${Date.now()}.xlsx`;
// Upload Blob that contains Excel file as an attachment
await JiraCloud.Issue.Attachment.addAttachments({
issueIdOrKey: ISSUE_KEY,
body: [{
content: await excelFile.arrayBuffer(),
fileName
}]
});
console.log(`New Excel file generated and uploaded: ${fileName}`);
}
interface EnvVars {
readonly ISSUE_KEY: string;
}
interface Student {
name: string;
dateOfBirth: Date,
cost: number;
paid: boolean;
}