Automatically add a comment to jira issue via Script Runner

Helen Ahlberg 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

1 vote
Answer accepted
Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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 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 Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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 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 Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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

Suggest an answer

Log in or Sign up to answer