Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Update Release description via script\Rest Endpoint

We have a custom button that we added via Script Fragments to the Release page.

We want to update a Release description field via this button.

How we can do it? Using some script\Rest endpoint or smth else?

Could you, please, advise.

Thanks.

1 answer

0 votes

Yes, normally, your web item button should have a "link" configuration.

This will be the URL that will trigger some action.

On an issue, you could use "run code and display a flag" ... but the framework to display that flag will not be available in the context of the release page.

But the question is ... how are you selecting which release to update the description for? Or did you add the web item to "atl.jira.version.admin.operations" ?

If so you will need to somehow wire some javascript yourself against that button to call a rest api so that you can identify which release item the user clicked and pass that to the rest call.. 

Hello.

I've added a Web panel into

12344.jpg

And It looks like this

1234.jpg

How I can add a script to this button? Also, maybe you have an example of such script which will update\change a Description field for Release?

If you've added a panel, presumably, you wrote some HTML code to display the button.

Just write some javascript that responds to the button click event.

Here is an example ... you'll probably want to grab the version id for the selected release. Then make an ajax call to some rest API that you'll have to create and possibly do something the API response:

def panelOutput = $/
<script>
function yourJsFunction(){
var versionId = AJS.$('#release-report-tabs-section').attr('data-version-id')
var payload = {"versionId": versionId}
AJS.$.ajax({
type: "POST",
url: "/rest/scriptrunner/latest/custom/yourRestAPI",
headers: { 'X-Atlassian-Token': 'no-check' },
data: JSON.stringify(payload),
success: function(data, status){
console.log(data);
require(['aui/flag'], function(flag) {
flag({
type: "success" ,
title: "Default description",
close: "auto",
body: "Default description added to current release"
});
});
},
error: function(data) {
console.log(data.responseText);
require(['aui/flag'], function(flag) {
flag({
type: "error" ,
title: "Error setting default description for release",
close: "manual",
body: data.responseText
});
});
}
})
}
</script>
<a class="aui-button aui-button-primary" href="javascript&colon;yourJsFunction()">CAB</a>&nbsp;
/$
writer.write(panelOutput)

Hello. Thank you for your response. Am I right that I need to create a REST Endpoint that will update a Description field?

url: "/rest/scriptrunner/latest/custom/yourRestAPI",

Yes, unless there is a built-in REST Api you can use, any change you want to do permanently has to be triggered somehow on the server and that's generally done with a custom rest api.

In this case, maybe the built-in api will work for you: https://docs.atlassian.com/software/jira/docs/api/REST/8.13.9/#api/2/version-updateVersion

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you