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)
I've solved it by the script above. But maybe somebody know how I can disable or hide this button after clicking for everyone? So we need to do only one click on this button
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've solved this. If anybody is interested
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.fullName;
}
});
var datos = {"description":"Release ID" + " " + versionId + " " + "was sent to SD by" + " " + user};
var parameters = JSON.stringify(datos);
AJS.$.ajax({
url: "/rest/api/2/version/" + versionId,
type: "PUT",
contentType: 'application/json',
data: parameters,
dataType: 'json',
async: false,
processData: false,
success: function(data, status){
var myFlag = AJS.flag({
type: 'success',
body: "Release ID" + " " + versionId + " " + "was sent to SD by" + " " + user,
});
},
error: function(error){
alert(JSON.stringify(error));
}
});
}
</script>
<a class="aui-button aui-button-primary" href="javascript:getVersionID()">CUSTOMBUTTON</a>
/$
writer.write(panelOutput)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.