How to append a text string to an issue's history?

Bruce Mohler September 9, 2019

Can anyone point me to materials or examples of how to append a text string to the history of an issue using ScriptRunner/Groovy.  I believe that this would be as a Behaviour, not a Listener or Post action.

I've spent days in Google Search looking for examples and all I've come away with is don't use the ComponentManager in favor of the ComponentAccessor.

Jira v8.0.2 / ScriptRunner v5.5.7.1

Thank you.

1 answer

1 accepted

0 votes
Answer accepted
Payne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 10, 2019

When do you wish for this to happen, and what exactly do you mean by the history - perhaps a comment?

Bruce Mohler September 10, 2019

On an Issue page, down under Activity, there are the following "tabs": All, Comments, Work Log, History, Activity, CI Builds.

The History tab seems to be keeping track of activities that are lower level than humans posting comments on an issue.

That's the History I was referring to.

What we'd like is that when we perform an action in ScriptRunner (for example, moving an issue from one status to another automatically) that our script would add something to the History documenting the source of that change.

Did that answer your question?

Payne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 10, 2019

We do something similar - using a post function we selectively transition an issue programmatically, and when we do, that shows in the issue history. Are you not getting this, or perhaps this isn't quite what you're doing?

jira.png

Bruce Mohler September 10, 2019

I didn't want to assume that it was there.

Now I will.  I'll assume that post functions that change something in an issue adds something to the History.

Thank you, Payne.

Bruce Mohler September 10, 2019

However...

What if it's happening in a ScriptRunner Groovy script as a Behaviour?  If the script changes something in an issue, will that always appear in the History?

If not, any suggestions on how to write something to the history?

Payne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 10, 2019

Yes; EVERY change (except comments and changes to comments) SHOULD be recorded in the History tab.

Bruce Mohler September 10, 2019

Perfect!

Thank you, Payne.

Payne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 10, 2019

The way we use Behaviours (and there may well be more functionality that I'm unaware of) is to do things in the UI as it renders. That by itself is nothing to record in history. However, if the user goes through with his action, then any data element changes will be recorded.

Bruce Mohler September 11, 2019

Ah, got it.  Thanks, Payne.

Suggest an answer

Log in or Sign up to answer