Workflows - Checking for a recent comment when validating a state change

Hiya,

I'm looking for some assistance in a workflow I'm creating.

USE CASE:
Some of our states require additional information to be present before we can allow that state to be set.
For example, we shouldn't be setting the state 'Won't Fix' without having spoken to the lead, and provided some solid reasons for the issue not being fixed, and so expect that reasoning to be present in the comment of the bug.

The easiest way I wish to approach this is to simply check for a recent comment when the state changes.

Something like..
when state becomes Wont fix     if (issue comments last updated > last minute)         message "Please supply a comment before closing this"         issue state = issue state oldvalue

If you could help me with this workflow, or something similar, that'd be great.

Thanks,
Jim
0
4 comments
It seems the most suitable way is the following:
rule Require comment on Won't fix
 
when State.becomes({Won't fix}) { 
  assert comments.added.isNotEmpty: "Please add comment in Command Window"; 
}

It allows move the issue State to 'Won't fix' only using Command Window(Ctrl+Alt+j) with provided comment, because of JT-10337.
0
Ah, I see, I think that option works well.
As it's a more restricted state, perhaps this extra requirement of using the command window will help to stop people using it without reason.

Thanks for your help.
0
In the end, we decided to turn off this workflow.
It just proved cumbersome to have to open the command window to change this state.
Especially as the user would have already added a comment seconds before attempting to change to this state.

It's a shame there's no way of checking for a comment being present within a minute or so, rather than enforcing a different method for changing the state.

Thanks for your help with this though anyway.
0
It's possible to enhance this workflow by checking the last comment creation time and its author:
rule won't fix 
 
when State.becomes({Won't fix}) { 
  var lastComment = comments.last; 
   
  if (lastComment.author != loggedInUser || comments.last.created + 1 minute < now) { 
    assert comments.added.isNotEmpty: "Please add comment in Command Window"; 
  } 
}
0

Please sign in to leave a comment.