Skip to content

Instantly share code, notes, and snippets.

@richkuz
Created October 25, 2023 22:20
Show Gist options
  • Save richkuz/c631140dafd24c65ec5fa37f270fdb69 to your computer and use it in GitHub Desktop.
Save richkuz/c631140dafd24c65ec5fa37f270fdb69 to your computer and use it in GitHub Desktop.
Bookmarklet to create Jira issues with default values provided

Jira Issue Create Bookmarklet

This bookmarklet lets you pop the Jira "Create Issue" dialog with values pre-populated. You have to be on a Jira page for this to work.

Create a new Bookmark in Chrome:

Bookmark name: “whatever”

URL:

javascript:var%20PROJECT_A%3D10090%2CPROJECT_B%3D10045%2CPROJECT_C%3D10025%2CTYPE_BUG%3D10004%2CTYPE_TASK%3D10002%2CTYPE_STORY%3D10001%2CTYPE_EPIC%3D1E4%2CCUSTOM_FIELD_STORY_POINTS%3D%22customfield_10023%22%2CCUSTOM_FIELD_PRODUCT%3D%22customfield_10121%22%2CCUSTOM_FIELD_BUG_FOUND_IN%3D%22customfield_10200%22%2CCUSTOM_FIELD_FAILURE_TYPE%3D%22customfield_10494%22%2CCUSTOM_FIELD_FREQUENCY%3D%22customfield_10495%22%2CCUSTOM_FIELD_STEPS_TO_REPRODUCE%3D%22customfield_10149%22%2CPRODUCT_A%3D10424%2CPRODUCT_B%3D10214%2CPRODUCT_C%3D10936%2CBUG_FOUND_IN_GENERAL_AVAILABILITY%3D10339%2CFAILURE_TYPE_INCORRECTLY_FUNCTIONING_MINOR%3D11330%2CFREQUENCY_1_CUSTOMER%3D11267%2CcreateIssue%3Drequire(%22quick-edit%2Fform%2Ffactory%2Fcreate-issue%22)%2C%24jscomp%24compprop0%3D%7B%7D%2Cdlg%3DcreateIssue(%7Bpid%3APROJECT_A%2CissueType%3ATYPE_BUG%2Cfields%3A(%24jscomp%24compprop0.description%3D%22%22%2C%24jscomp%24compprop0.environment%3D%22blank%22%2C%24jscomp%24compprop0%5BCUSTOM_FIELD_STORY_POINTS%5D%3D3%2C%24jscomp%24compprop0%5BCUSTOM_FIELD_STEPS_TO_REPRODUCE%5D%3D%22Steps%20to%20reproduce%20(include%20screenshots%2C%20recordings)%3A%5Cn%5CnExpected%20results%3A%5Cn%5CnActual%20results%3A%5Cn%5Cn%22%2C%24jscomp%24compprop0%5BCUSTOM_FIELD_FREQUENCY%5D%3DFREQUENCY_1_CUSTOMER%2C%24jscomp%24compprop0%5BCUSTOM_FIELD_FAILURE_TYPE%5D%3DFAILURE_TYPE_INCORRECTLY_FUNCTIONING_MINOR%2C%24jscomp%24compprop0%5BCUSTOM_FIELD_BUG_FOUND_IN%5D%3DBUG_FOUND_IN_GENERAL_AVAILABILITY%2C%24jscomp%24compprop0%5BCUSTOM_FIELD_PRODUCT%5D%3DPRODUCT_A%2C%24jscomp%24compprop0)%7D).asDialog(%7BwindowTitle%3A%22New%20Bug%22%7D)%3Bdlg.show()%3Bvoid+0

Here’s the raw source of the bookmarklet. You can edit it and re-generate the bookmarklet code by pasting the code into YourJS Bookmarklet Creator

const PROJECT_A = 10090;
const PROJECT_B = 10045;
const PROJECT_C = 10025;
// From Project Settings->Issue Types
const TYPE_BUG = 10004;
const TYPE_TASK = 10002;
const TYPE_STORY = 10001;
const TYPE_EPIC = 10000;

// Inspect element to see the ID of a custom field input field
const CUSTOM_FIELD_STORY_POINTS = 'customfield_10023';
const CUSTOM_FIELD_PRODUCT = 'customfield_10121';
const CUSTOM_FIELD_BUG_FOUND_IN = 'customfield_10200';
const CUSTOM_FIELD_FAILURE_TYPE = 'customfield_10494';
const CUSTOM_FIELD_FREQUENCY = 'customfield_10495';
const CUSTOM_FIELD_STEPS_TO_REPRODUCE = 'customfield_10149';

// To get dropdown field values:
//  - Go here: /secure/admin/ConfigureCustomField!default.jspa?customFieldId=10030
//  - Edit Options
//  - Hover over the value's edit link and look at the selectedValue in the URL tip
const PRODUCT_A = 10424;
const PRODUCT_B= 10214;
const PRODUCT_C = 10936;
const BUG_FOUND_IN_GENERAL_AVAILABILITY = 10339;
const FAILURE_TYPE_INCORRECTLY_FUNCTIONING_MINOR = 11330;
const FREQUENCY_1_CUSTOMER = 11267;

var createIssue = require('quick-edit/form/factory/create-issue');
var dlg = createIssue({
    pid: PROJECT_A,
    issueType : TYPE_BUG,
    fields: {
        description: '',
        environment: 'blank',
        [CUSTOM_FIELD_STORY_POINTS]: 3,
        [CUSTOM_FIELD_STEPS_TO_REPRODUCE]: "Steps to reproduce (include screenshots, recordings):\n\n" +
            "Expected results:\n\n" +
            "Actual results:\n\n",
        [CUSTOM_FIELD_FREQUENCY]: FREQUENCY_1_CUSTOMER,
        [CUSTOM_FIELD_FAILURE_TYPE]: FAILURE_TYPE_INCORRECTLY_FUNCTIONING_MINOR,
        [CUSTOM_FIELD_BUG_FOUND_IN]: BUG_FOUND_IN_GENERAL_AVAILABILITY,
        [CUSTOM_FIELD_PRODUCT]: PRODUCT_A
    }
}).asDialog({
    windowTitle : "New Bug"
});
dlg.show();

// It's possible to set values after the dialog is popped, too:
// dlg.$content.find('#description').val(`My description`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment