Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to make the 'Comment' field required based on time the last comment was created?

Дмитрий Вандеев
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 14, 2023

Hi Everyone,

We want to make the "comment" field on the transition between statuses become required only if the last comment on the task was left more than 1 minute ago. Trying to do this with Scriptrunner Behaviors:

 

import com.opensymphony.workflow.InvalidInputException
import java.time.LocalDateTime
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.component.ComponentAccessor

def issue = ComponentAccessor.getIssueManager().getIssueObject("TEST-1")
def commentManager = ComponentAccessor.getCommentManager()
def comment = commentManager.getLastComment (issue)
def date = comment.getCreated()
def oneMinute = LocalDateTime.now().getMinute() - date.getMinutes()
if (oneMinute >1)
{throw new InvalidInputException( "comment required")}

but it doesn't work
Any help would be gratefully received!

1 answer

1 accepted

0 votes
Answer accepted
Ram Kumar Aravindakshan _Adaptavist_
Community Champion
August 16, 2023

Hi @Дмитрий Вандеев

To answer your question, in Jira Cloud, at the moment this is not doable because only a limited number of field types are able to work with the Behaviour and the Comment field is not included in it.

For more information, please refer to this ScriptRunner for Jira Cloud documentation.

Thank you and Kind regards,

Ram

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events