Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

post function script to fetch the latest comment with default message

Durgesh Masurkar March 28, 2024

I have applied one script in workflow post function, the use of script is to give me the latest comment.

I'm doling a transition from A status to B status, during this time I'm setting a default comment with post function custom script.


on the same transition I have comment screen as well:


Here my question is:

I am doing this transition A->B, if I'm not adding comment manually and directly doing the transition then the default comment is coming correctly.(Which is added in post function)

but what if I added a comment any message in the Response to customer section

it should give me "my manually added message/comment" + "default/static comment message"


here I'm getting my previous last comment(which was exactly added before performing the transition), but it is not giving me the last comment which I have added on the transition screen + Default/static message ? Why?


In very short- I need manually added message/comment + default/static comment??


Anyone's help regarding this matter would be really appreciated.


1 answer

0 votes
Kseniia Trushnikova
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 29, 2024

Hi @Durgesh Masurkar,

I don't use Scriptrunner but I use JMWE and I guess this may work for you too. Correct me please if I misunderstood your question.

If you want to add two comments into one, you can transform a transition comment by adding this script above the system post function "Add a comment to an issue if one is entered during a transition":

//Get a transition comment
def originalTransientVarsComment = transientVars.comment ?: ""

//Define the default comment
def defaultComment = "This is a default comment."

//Check if a comment has been added on the transition screen, then update it
if (transientVars.comment) {
transientVars.comment = originalTransientVarsComment + "\n\n" + defaultComment
} else {
transientVars.comment = defaultComment
  • If no comments were added during the transition, only the default comment will be added to the ticket.
  • If a transition comment is present, it and the default comment will be added to the ticket as one comment.

Here's the example. I added a comment during the transition and this is what was added to my ticket:

Screenshot 2024-03-29 at 23.07.08.png

Durgesh Masurkar March 30, 2024

Hi @Kseniia Trushnikova ,


Thanks for sharing the details, I'll check and update you regarding this.


Thank you for your support!!!

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events