We would like to receive a list of projects by Rest API and select one in a custom field.
We have an API connection that returns a list of values.
Can I create a custom field that shows in a dropdown the list so I can select one and save it to the issue?
Any suggestions or similar integrations
There is now a Jira cloud App called External Data for Jira Fields that allows to synchronise external data with a dropdown custom field.
You can connect your REST API as a data source and define how the dropdown custom field should be populated. From then on the dropdown will stay in sync with your REST API (new values will be created and missing ones disabled)
Hope this helps.
Best,
Thomas
Disclaimer: I'm the product manager of this App.
Hi Ellen,
The default drop down list by default requires pre-defined value. As your list is dynamic, it may be difficult to do that with a single list. There might be other ways to do it but a quick solution will be to use a drop down list and a read only text field. Here is an example:
1. Create two custom fields, a drop down and a text field
2. Put the two fields on the Create Issue and Edit Issue screens
3. Put the text field in the view screen only
4. Go to Settings > Custom fields > Edit the drop down field and put the following in the description field:
<script type="text/javascript">
//Get projects
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://localhost:8081/rest/api/2/project", false);
xhr.send();
var obj = JSON.parse(xhr.responseText);
//Set dropdown field values
var list = document.getElementById("customfield_10800");
for (i = 0; i < obj.length; i++) {
var option = document.createElement("option");
option.text = obj[i].key;
list.add(option);
}
//Set the text field value to the selected project
AJS.$(document).ready(function() {
AJS.$('#customfield_10700').prop('readonly', true);
AJS.$('#customfield_10800').on('change', function() {
var project = $(this).val();
AJS.$('#customfield_10700').val(project);
});
//Dropdown lists require predefined values, set the selected value back to the default value submit button is clicked
AJS.$('#create-issue-submit').click(function() {
AJS.$('#customfield_10800').val('0');
});
AJS.$('#edit-issue-submit').click(function() {
AJS.$('#customfield_10800').val('0');
});
});
</script>
You will need to replace the custom field IDs with your own IDs.
Best Regards,
Muaamar Amer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This worked for me, thanks.
Any idea how to append to a label or component using javascript, instead of a text box?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Wouldn't that throw cross site scripting errors?
And is there a better option these days?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Steven Cavanagh was thinking the same. Is there another method for solving this? Data Connections for JSM projects is so simple to use - is there a way of exposing those dropdowns to Software (now just "Jira") projects?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.