I already created a web item button.
I already created a REST endpoint to make my groovy code work when I click the button.
What I need is - get user input for my groovy code. (I guess it is done with JS in web resources but I'm not sure how)
Is this possible?
Hello @Noam Twena
May I please firstly confirm by web item you do mean this?
Further more, what is "Your Groovy Code"?
Is it a Scriptrunner REST endpoint that accepts some query parameters?
What section have you placed this on?
What is the button? By this I mean is it a <button /> or is it an anchor with css button classes?
Is the file that contains the button a velocity template?
If I am understanding you correctly then may I propose the following.
1. If you are using a button, it may be easier to use an anchor with an Ajax call to your custom rest endpoint. If you use a button then the href property will not do strange things when clicked. Consider which suites your use case better.
2. Bind a javascript function that contains the Ajax call in the On init function(Document ready) is the button in the DOM when the page loads?
What happens if I spam click the button? (Debounce / disable / remove) the element on click and a successful Ajax response.
What is the response going to do to the page? Add some stuff / nothing only a 200 response is needed to confirm a successful call.
Have you looked at AUI, this is useful for DC and server as well.
If you use velocity will the file just contain the javascript?
If not it will need to be registered as a downloadable resource in the plugin.xml
Is this even a custom plugin?
Graham
Hi @Noam Twena and welcome,
in order to retrieve information about logged in user you could try the following code :
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.user.ApplicationUser;
ApplicationUser loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
Hope this helps,
Fabio
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.