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

Can we run a script for a button click event

Hi I just created a button using Script fragment. I want to run a certain script on clicking the button is it possible?

1 answer

0 votes

Yes, your button will have to be linked to a scriptrunner custom REST endpoint and that endpoint will run your code.

The easiest option is to select "run code and show a flag" in your web item fragment, then your rest endpoint just has to return a flag map to show the result of running your script.

Of course, you could always create your own javascript to react to the button click and call your rest endpoint.

Hey thanks for your answer, but I'm new to jira and script runner. Can you please explain how to link the button to an endpoint and run the code?

Thanks for your help

I came across another scenario. Will I be able to access the input I give in the text box while running the script?

 

For example: let's say I have a text box and a button. I need to display the information entered into the text box while clicking the button.

If you're looking to provide input to your REST endpoint and your script, then you will have to follow some of the instructions in that adaptavist documentation page under Dialogs (Advanced) section.

Your dialog will include the form and input field you want the users to fill in. The form button will have to have some javascript to call your rest endpoint and include the user's input.

But if you are dealing with a jira issue, it might be easier to have a transition (from any status to itself) and a transition screen provide you the form and the post function to execute your script.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

⏰ Day in the life of a Jira Admin!

Hello Community! We thoroughly enjoyed this just-for-fun conversation in the Jira Admin Group about what it's like to be a Jira Admin. For #JiraJuly, our talented designers created these graphics t...

882 views 2 22
Read article

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