Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

How to add a button that executes a transition on another ticket?

I have Jira with ScriptRunner.

I have a Request issue type and an Approval issue type. Multiple approval issues are related to a request issue. This represents multiple approvals for the request.

The user for each approval could click on the linked approval issue and then click the appropriate transition which prompts for a comment. 

However I'd like to make it a little easier for users that aren't used to Jira. I'd like there to be "Approve" and "Reject" buttons at the top of the request issue type that will execute the appropriate transition on the related issue AND prompt the user for the comment like they normally would if following the transition manually.

I have figured out how to get ScriptRunner to add an additional button to the top of the Jira view screen. I can also make this button conditionally visible based on the logged in user and the linked approval issues.

What I haven't figured out is if there is a way have that button execute the transition in the related ticket and prompt for the comment. I did find that if I paste the link for the button on the approval issue into my browser window I can get the comment dialog to show up. However putting that link into a web panel that doesn't appear to work.

Anyone have ideas on how to execute this transition?

Alternatively I could prompt for the comment in a dialog that comes up from the custom button and then execute the transition on the back end. However I haven't figured out how to add an input field to the custom dialog and capture it's output yet.

 

2 answers

1 accepted

0 votes
Answer accepted

Why don't you build that into the Request workflow rather than trying to use custom buttons?

Create global transitions where the target status is the current status (so your request issue won't actually change).

  • Add a transition screen with only the comment
  • The workflow condition can determine when to show or hide the approve/reject button.
  • The validator can ensure the comment is entered.
  • A custom post function can look for the linked Approval issue and apply the desired transition.

You can have the comment entered by the user in the form replicated on the approval ticket. And if having the comment on both issue is a problem for you, you might be able to delete the comment either during or after the transition (not sure about this one).

I was trying to avoid the extra comments, but maybe this is the best option.

Yeah, building a whole custom form to avoid an extra comment seems overkill.

Another option is to use a custom comment field on your request issue type that is only visible in the approve/reject transition. This would be easier to clear out the value with minimal history (or perhaps even before it is stored by the post function).

0 votes
Payne Community Leader Apr 12, 2021

I have done something like this. Below are sections of my script that illustrate how I went about this. Hope you find it useful.

//The method that actually performs the transition
def runApproveTransition(IssueService issueService,ApplicationUser jiraAdminUser,Long subtaskId,int transitionApproveSubtask)
{
IssueInputParameters issueIP = issueService.newIssueInputParameters()
TransitionOptions transitionOptions = new TransitionOptions.Builder().skipConditions().skipPermissions().skipValidators().build()
TransitionValidationResult validationResult = issueService.validateTransition(jiraAdminUser, subtaskId, transitionApproveSubtask, issueIP, transitionOptions)
issueService.transition(jiraAdminUser, validationResult)
}

//A call to that method
runApproveTransition(issueService,jiraAdminUser,subtaskCreated.id,transitionApproveSubtask)

//Definitions of the passed variables
IssueService issueService = ComponentAccessor.getIssueService()
ApplicationUser jiraAdminUser = ComponentAccessor.getUserManager().getUserByName("jiraadmin")
subtaskCreated // is the Issue that we wish to transtion
final int transitionApproveSubtask = 41

And, of course, you'll need a few imports. Hopefully this will get you headed in the right direction.

This part I already know how to do. What I don't know how to do is prompt the user for the comment that I want them to enter on the transition that I am executing programatically. That or redirect the user's browser as if they had clicked the transition button on the approval ticket.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

129 views 1 1
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