Skip to content

Instantly share code, notes, and snippets.

@LaughDonor
Created October 8, 2018 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LaughDonor/09cfe7691dbeb0f3a47fa38c049e8337 to your computer and use it in GitHub Desktop.
Save LaughDonor/09cfe7691dbeb0f3a47fa38c049e8337 to your computer and use it in GitHub Desktop.
Prefill JIRA Subtask Fields
// ==UserScript==
// @name Pre-fill SubTask Info
// @namespace https://jira.solutionstarit.com/
// @version 0.1
// @description Pre-fill JIRA Subtask information
// @author Sunny Patel
// @updateUrl https://gist.github.com/laughdonor/09cfe7691dbeb0f3a47fa38c049e8337/raw/jira-subtask-dev.user.js
// @match https://jira.solutionstarit.com/browse/*
// @grant none
// ==/UserScript==
/* globals $ JIRA */
const fields = {summary: 'Dev - Coding and Review'};
const role = "Dev"; // Or "QA", or "" as applicable
(function() {
'use strict';
const roles = {'QA': 'customfield_11821', 'Dev': 'customfield_11823'};
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(evt, node, type) {
if( type === "dialogReady" && node.parent("#create-subtask-dialog").length ) {
$("#assign-to-me-trigger").click();
if( role.length )
fields[roles[role]] = $('img.aui-ss-entity-icon', '#assignee-single-select').attr('src').match(/ownerId=(\w+)/)[1];
$.each(fields, (id, val) => $("#" + id).val(val));
const due = $("#duedate-trigger").click();
setTimeout(() => due.get(0).scrollIntoView(), 20);
}
});
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment