How to get comments in screen for postfunction via Groovy Script Runner?

How to get comments in screen for postfunction via Groovy Script Runner?

3 answers

1 accepted

3 votes
Henning Tietgens Community Champion May 14, 2013
transientVars.comment as String

Have fun,

Henning

Hey Henning

Not worked

Instead of last comment, I want to send comment at screen in email using https://jamieechlin.atlassian.net/wiki/display/GRV/Built-In+Scripts#Send+a+custom+email

I got error!

groovy.lang.MissingPropertyException: No such property: transientVars for class: groovy.tmp.templates.GStringTemplateScript55

Henning Tietgens Community Champion May 14, 2013

Ah ok, i thought you would like to access the comment from the transition screen from a scripted post function.

Did you surround my code with ${} within the email template? Maybe it helps if you post what you already tried.

Henning Tietgens Community Champion May 14, 2013

I'm only guessing.. and if you try

<% out << transientVars.comment %>

?

Yes, but not work

Henning Tietgens Community Champion May 14, 2013

I tried it by myself. If I write this

Last Comment: <% out << transientVars.comment %>

as "Email template" it works. If no comment was provided during transition you get

Last Comment: null

as email, so you should test for null before you insert the comment.

Does not work . Here is my configuration

Henning Tietgens Community Champion May 14, 2013

That may be the problem. I only tried it as a real workflow postfunction because transientVars is only there for real transitions.

I can't see a configuration in your previous comment...

Did you try in admin panel or in workflow?

I am trying in admin panel and receiving same error?!

Thanks! I will try in a postfunction.

Hey Henning!

How to check for null?

Any documentation link for transientVars functions would be great!!!

Henning Tietgens Community Champion May 15, 2013

If you look at the linked page you provided earlier, there is an example on how to check for null for the last comment (https://jamieechlin.atlassian.net/wiki/display/GRV/Built-In+Scripts#Built-InScripts-Sendacustomemail). In general it's

if (transientVars?.comment) {...}

I don't know about a documentation about the transientVars. It's a Map, and it contains different fields in different situations. You could take a look at the content if you print the content to the log.

log.error "transientVars: $transientVars"

Henning

Does not work!!

Henning Tietgens Community Champion May 15, 2013

What? A little more information would be nice. What did you do? How could you see that it does not work? Did you get any errors?

I used, but no message is received.

Last Comment:
<% if(transientVars?.comment)
out << transientVars.comment
%>

Henning Tietgens Community Champion May 15, 2013

Any errors in the log?

Henning Tietgens Community Champion May 15, 2013

Uh oh, you should change that if you want to go on with scripting JIRA. Maybe your IT department could give you read only access.

Did it work without the if statement?

Yes! it work without if statement.

Can you test on your side?

I do not have access on log file.

Henning Tietgens Community Champion May 15, 2013

Ok, I'll test it. Give me a moment, please :-)

Henning Tietgens Community Champion May 15, 2013

Works perfect. With or without comment.

Maybe your condition is not met? Do you publish the changed workflow?

Many many thanks! It works

"Not works".

Wow - way to make it really really hard for other people to help you. Well done Henning... you have more patience than me.

Just adding a "thank you". This is exactly what I was trying to do this morning.

I'm also gettting groovy.lang.MissingPropertyException: No such property: transientVars for class:

I'm using the post function Comment linked issues Function for this transition and trying to catch the comment from the transition screen.

It says issue, issueObject and log are available objects so transientVars isn't?

 

Are you definitely using ScriptRunner? Your previous question suggested you were using another plugin.

My bad, it was indeed JIRA Misc.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published yesterday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

38 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you