How to set a field required via an Issue Collector although it is optional in JIRA ?

Olivier Crozier October 26, 2016

This question is in reference to Atlassian Documentation: Advanced use of the JIRA issue collector

For example I want to set the field description required when submitting an issue via a given Issue Collector.

The field description is optional in JIRA with no intention to set it required. How can I do?

Looking further into the Advanced use of the JIRA issue collector documentation, I also don't understand the usage of the fieldValues properties as a function. What does it do? Can I use this function to achieve my goal?

4 answers

1 accepted

0 votes
Answer accepted
Olivier Crozier February 9, 2017

Eventually I ended up with my own Custom Issue Collector.

The goal is to mimic the behaviour of the native JIRA Issue Collector while offering more flexibility.
You click on a button to open a form, and you click on submit to create the issue.
Every Custom Issue Collector has its own label to stamp the issues created through it.

Form:
https://www.formget.com/how-to-create-pop-up-contact-form-using-javascript/

Submit using REST API:
https://api.jquery.com/jQuery.ajax/
https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis

Code in Confluence macro HTML:

$.ajax({
    type: "POST",
    url: "https://ourdomain/jira/rest/api/2/issue/",
    dataType: "json",
    contentType: "application/json",
    data: JSON.stringify(issue),
    async:false,
    xhrFields: {
      withCredentials: true
    },
    success: function (data, status, result) {
      console.log("ajax call succeeded", data, status, result);
      popup_message(data.key); //show new issue with clickable link and submit the form
    },
    error: function (result, status, error) {
      console.log("Internal Error ajax call", result, status, error);
      alert("Error:" +JSON.stringify(result) +"," +status +"," +error +".");
    },
  });

CONF URL = https://ourdomain/confluence.
JIRA URL = https://ourdomain/jira

0 votes
Vladimir Horev _Raley_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 24, 2017

Simple option to make a field mandatory if you don't want to hack: Jirassimo IntakeForms

Best, Vlad

 

0 votes
Olivier Crozier November 8, 2016

Another interesting solution would be to mimic the predefined JIRA Issue Collector named Got Feedback?.

Creating a new JIRA Issue Collector from the Issue Collector template named Got Feedback? produces a screen with any fields (not JIRA fields) all required.

At submit the values entered at the Issue Collector fields are grouped and inserted within the JIRA issue description.

How can we create such a similar custom JIRA Issue Collector?

  • With a form to collect the required information ie anything such as a radio field, a list field, a string field, a text field...
  • And the collected values stored within one or several JIRA issue fields at submit.
0 votes
Olivier Crozier October 27, 2016

Basically there would be a simple solution if I could patch the HTML before showing the JIRA Issue Collector dialog.

Example with 3 fields Summary, Severity (a custom field), and Description of type string, list, and text.

The HTML on the page contains 3 elements:

<input class="text long-field" id="summary" name="summary" type="text" value="">


<select class="select" name="customfield_10159" id="customfield_10159">
    <option value="-1">None</option>
    <option value="10030">Critical</option>
    <option value="10031">Serious</option>
    <option value="10032">Non-critical</option>
</select>
 
<textarea class="textarea long-field wiki-textfield long-field mentionable" id="description" name="description" rows="12" wrap="virtual" data-projectkey="CMTOOLSPRCR" style="overflow-y: auto; height: 200px;"></textarea>

 

My need would be achieved if patching the HTML as follow:

<input class="text long-field" id="summary" name="summary" type="text" value="" required="">


<select class="select" name="customfield_10159" id="customfield_10159" required="">
    <option value="">None</option>
    <option value="10030">Critical</option>
    <option value="10031">Serious</option>
    <option value="10032">Non-critical</option>
</select>
 
<textarea class="textarea long-field wiki-textfield long-field mentionable" id="description" name="description" rows="12" wrap="virtual" data-projectkey="CMTOOLSPRCR" style="overflow-y: auto; height: 200px;" required=""></textarea>

Which consists in:

  1. Adding the attribute required="" on inside <input>, <select>, and <textarea>.
  2. Change the default value of the list from "-1" to "".

 

The thing is I don't know how to do this. Any clue?

Suggest an answer

Log in or Sign up to answer