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.
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).
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).
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).
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)
//A call to that method
//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.
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...
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