How to keep Google sheets and Jira sync code example
Example: google form response to jira rest api
// This script takes the user inputs from the Google Form, and will create a JIRA issue when the form is submitted via the REST API// Takes user input info, and passes it into an event parameter "e"function createIssue(e){// Assign variables to the form data submitted by the requestor from the spreasheet associated with the Google form.// NOTE: Update the [n] to the cell value in your spreadsheet.var subject = e.values[1]; var priority = e.values[2]; var desc = e.values[3]; var deadline = e.values[4]; var email = e.values[5] var description = "Description: "+desc var url = "https://<>.atlassian.net/rest/api/latest/issue"; // The POST data for the JIRA API call var data = { "fields": { "project":{ "key": "<>" }, "summary": subject, "description": description, "priority": {"name": priority}, "issuetype":{ "name": "Task" } } };//// Turn all the post data into a JSON string to be send to the API// var payload = JSON.stringify(data); var headers = { "content-type": "application/json", "Accept": "application/json", "authorization": "Basic BASE64 of <>" };// A final few options to complete the JSON string var options = { "content-type": "application/json", "method": "POST", "headers": headers, "payload": payload };//// Make the HTTP call to the JIRA API// var response = UrlFetchApp.fetch(url, options); Logger.log(response.getContentText());//// Parse the JSON response to use the Issue Key returned by the API in the email// var dataAll = JSON.parse(response.getContentText()); var issueKey = dataAll.key Logger.log(dataAll)//// Assign variables for the email reposnse// var emailSubject = "Your request no. " + issueKey + " has been created"; var emailSubject = "Your request no. " + issueKey + " has been created"; var emailBody = "Thank you for your ticket submission." + "\n\n" + "Your request has been created, your reference is " + issueKey + " which can be accessed via the following link to the JIRA system:" + "\n\n" + "https://<>.atlassian.net/browse/"+ issueKey + "\n\n" + "We will be in touch soon to discuss your ticket submission. " +//// Send an email to the requestor//MailApp.sendEmail(email, emailSubject, emailBody, { name: '' }) }