Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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 display a comment dialog using ScriptRunner Validator? Edited

I have a requirement in which the comment dialog should be shown during a workflow transition if the current user did not previously provide a comment. 

Is there any JIRA APIs that can be used in the ScriptRunner Validator to display a comment dialog for the user to enter comments?

Thanks,

Tom

 

2 answers

1 accepted

0 votes
Answer accepted
Ivan Tovbin Community Leader Jun 01, 2018

Hi Tom,

You don't need Scriptrunner for this. Simply add a screen to your transition. Check out this documentation for more info.

Thanks Ivan.

I have no issue posting the comment dialog on transition by adding a screen and using the "Comment Required Validator (JMWE add-on)" Validator, but this is not what I am trying to achieve.

The use case that I am trying to achieve is to post the comment dialog only if the last comment was not added by the user doing the transitioning.

For example, if the last comment added is from the same user that wants to progress the issue to the next state, no comment dialog appears for the transition.  If the last comment is from a different user, a comment dialog appears before allowing the transition.

I believe through ScriptRunner, we can obtain the user who added the last comment, but is there an API to invoke the comment dialog (which is a transition screen)?

Any hint or direction to implement this use case is appreciated.

Thanks,

Tom

Ivan Tovbin Community Leader Jun 03, 2018

Ah, I see. Thank you for the clarification. This is totally doable. What I would do, if I had a similar issue is I would created TWO transitions, one with a comment screen and one without. Then I would configure two conditions, one for each transition. One condition would show the transition WITHOUT a comment screen only if the author of the latest comment is the current user. And the other condition would show the transition WITH a comment screen only if the author of the latest comment is NOT the current user. 

As for the conditions themselves you can even use JMWE to write a scripted condition which would check the author of the latest comment against the current user.

If you need help with the scripts please do let me know, I might be able to help.

Hi Ivan,

Thank you for your advice.

Based on your suggestion, assume transition "A_B" doesn't have the comment screen, and transition "A__B"  has the comment screen.  Now lets assume the condition is fulfilled where the author of the latest comment is NOT the current user so the transition button "A__B" is shown.  Clicking on "A__B" will show the comment screen.

But what if there's a scenario where the current user added a comment and then clicked on "A__B".  In this case, the author of the latest comment is the current user so clicking on "A__B" will show the comment screen which we do not want.  How do we bypass the comment screen at this point?

Also, any pointer on writing the scripts for the conditions is appreciated.

Thanks,

Tom

Ivan Tovbin Community Leader Jun 05, 2018

If the current user will add a comment BEFORE clicking on the transition button the the condition for a transition WITHOUT a screen will be met and it's button will appear. At the same time, the condition for a transition WITH a screen will no longer be met and so it's button will disappear.

As for the scripts, here's the code for both cases.

Transition WITH a screen:

import com.atlassian.jira.component.ComponentAccessor

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueComments = ComponentAccessor.getCommentManager().getComments(issue)

if (issueComments[issueComments.size()-1].getAuthorApplicationUser().equals(currentUser)){
return false
}
return true

 

Transition WITHOUT a screen:

import com.atlassian.jira.component.ComponentAccessor

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueComments = ComponentAccessor.getCommentManager().getComments(issue)

if (issueComments[issueComments.size()-1].getAuthorApplicationUser().equals(currentUser)){
return true
}
return false

Thanks Ivan.  Your solution works very well.

Accidently answer instead of reply.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

4,013 views 11 5
Join discussion

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