Hello. We have a script want we want to use to upgrade a Description field for Releases by clicking on the custom button (added via Script Fragment).
But nothing happens when we add this script to the button and click.
Need some help to fix it, please.
def panelOutput = $/
<script>
function getVersionID()
{
var versionId = AJS.$('#release-report-tabs-section').attr('data-version-id')
var user;
AJS.$.ajax({
url: "/rest/gadget/1.0/currentUser",
type: 'get',
dataType: 'json',
async: false,
success: function(data) {
user = data.username;
}
});
var dataObject = {"update":{"description":[{"edit":{"Updated by" user}}]}};
AJS.$.ajax({
type: 'PUT',
contentType: 'application/json',
url: "/rest/api/2/version/" + versionId,
dataType: 'json',
async: false,
data: JSON.stringify(dataObject),
success: function(response){ alert("yes"); },
error: function(error){ alert(JSON.stringify(error)); }
});
}
</script>
<a class="aui-button aui-button-primary" href="javascript:getVersionID()">CUSTOMBUTTON</a>
/$
writer.write(panelOutput)