I'm trying to get access to the name in the first component for each issue and don't seem to be able to figure this out. There will only ever be one item in the component array. In this case it should return me "KBR" Here's my code:
<script>
// Gets the data related to items added in sprint pi-19.3
$(document).ready(function() {
$.getJSON("./json/PI-19/taxonomyAddedAfterSprintStart.19.3.json", function(data_add) {
var jira_data_add = '';
$.each(data_add.issues, function(key, val){
jira_data_add += '<tr>';
jira_data_add += '<td>'+val.key+'</td>';
jira_data_add += '<td>'+val.fields.issuetype.name+'</td>';
jira_data_add += '<td>'+val.fields.summary+'</td>';
jira_data_add += '<td class="centered-cell">'+val.fields.customfield_10013+'</td>'; // Story Points Custom Field
jira_data_add += '<td class="centered-cell">'+val.fields.status.name+'</td>';
jira_data_add += '<td class="centered-cell">'+val.fields.components.name+'</td>';
});
jira_data_add += '</tr>';
$('#sprint-items-added-pi-nineteen-c').append(jira_data_add);
});
});
</script>
Here's the JSON
"issues": [
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"id": "1286516",
"self": "https://xxx",
"key": "TAXY-662",
"fields": {
"components": [
{
"self": "https://xxx",
"id": "40920",
"name": "KBR"
}
],
}
I've also tried:
jira_data_add += '<td class="centered-cell">'+val.fields.components[0].name+'</td>';
This does not work - I get undefined back
I've also tried:
jira_data_add += '<td class="centered-cell">'+val.fields.components["name"]+'</td>';
Again I get undefined back in the table