Last active
February 19, 2023 14:36
-
-
Save Ishmam156/09a65191731fc2e6532c37a453514733 to your computer and use it in GitHub Desktop.
Short appscript code to help automate creation of issues in Clickup when a user is submitting a Google Form.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const AUTHKEY = 'your_clickup_auth_token' | |
const LIST_ID = 'your_list_id_in_clickup' | |
const priority_matrix = { | |
"Urgent" : 1, | |
"High" : 2, | |
"Normal" : 3, | |
"Low" : 4, | |
} | |
function mySubmit(e) { | |
const result = JSON.stringify(e) | |
const JSONresult = JSON.parse(result) | |
Logger.log(JSONresult) | |
const date = new Date().toLocaleString('en-us',{day: 'numeric', month:'short', year:'numeric'}) | |
const query = 'custom_task_ids=true&team_id=123'; | |
const listId = LIST_ID; | |
const options = { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', | |
Authorization: AUTHKEY | |
}, | |
payload: JSON.stringify({ | |
name: `IT Issue ${JSONresult['range']['rowStart'] - 1} - ${date}`, // Getting row number to help create numbering | |
markdown_description: `Describe the issue based on items from the form`, // Use JSONresult['namedValues'] to see what you're receiving from the form | |
assignees: [123456], // Input clickup member ID of who the issue should be assigned to | |
tags: ['test tag'], // Text name of what the tag should be | |
priority: priority_matrix[JSONresult['namedValues']['What is the priority level of the issue?']] | |
}) | |
}; | |
const resp = UrlFetchApp.fetch( | |
'https://api.clickup.com/api/v2/list/' + listId + '/task?' + query, | |
options | |
); | |
const data = JSON.parse(resp.getContentText()); | |
Logger.log(data); | |
} | |
// In Appscript, you need to run this function once to provide the authorization for future usage of the trigger | |
function createTrigger(){ | |
const sheet = SpreadsheetApp.openById("your_google_sheet_id"); | |
ScriptApp.newTrigger('mySubmit') | |
.forSpreadsheet(sheet) | |
.onFormSubmit() | |
.create(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cool one!