The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

Automatically add a comment to jira issue via Script Runner

Helen Ahlberg
Contributor
May 6, 2021

Automatically add a comment to jira issue

how can I do this via script runner? Jira server v8.5.0

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
Answer accepted
Martin Bayer _MoroSystems_ s_r_o__
Community Champion
May 6, 2021

Hi @Helen Ahlberg you need to use postfunction. Snippet with the example code is here: https://library.adaptavist.com/entity/add-comment-to-an-issue-in-a-post-function

Helen Ahlberg
Contributor
May 6, 2021

I want to have a pre-defined value comment on every transaction.

Not a comment after the action is done but during the transaction

ex

My issue is moved from A to B and when pressing go_to_B I want a predefined value shown

ex: Enter the check you have done:

so that users can enter a comment after, And I want all of this to end up under Comment (not a custom field)

Is this possible?

Martin Bayer _MoroSystems_ s_r_o__
Community Champion
May 6, 2021

Hi @Helen Ahlberg are you familiar with Behaviours (https://scriptrunner.adaptavist.com/6.20.0/jira/behaviours-overview.html)?

You can use this code in Behaviours script

def predefinedComment = "some comment"
getFieldById("comment").setFormValue(predefinedComment)
Helen Ahlberg
Contributor
May 6, 2021

OK - but this will give me a pre-defined comment when just creating the issue?

 

We have behaviuor scripts that populate text in the Description field but this only happens with create issue.

 

My user want to have different pre-define commenttext when tranfering the issue in its workflow  - is this possible?
Question -> 

getFieldById("comment")

is this the Jira 'field' comment?

Martin Bayer _MoroSystems_ s_r_o__
Community Champion
May 7, 2021

Yes, behaviours works on transitions similary. You can use conditions in your source code (transition name, target status name...)

https://library.adaptavist.com/entity/limit-a-behaviour-to-a-specific-workflow-action

DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events