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).
I was trying to avoid the extra comments, but maybe this is the best option.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Validate your expertise in managing Jira Service Projects for Cloud. Master configuration, optimize workflows, and manage users seamlessly. Earn global 🗺️ recognition and advance your career as a trusted Jira Service management expert.
Get Certified! ✍️Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.