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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

5 votes
Answer accepted
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

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.

I'm only guessing.. and if you try

<% out << transientVars.comment %>

?

Yes, but not work

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

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!!!

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!!

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
%>

Like mani@123 likes this

Any errors in the log?

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?

Like mani@123 likes this

I do not have access on log file.

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

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
TAGS
Community showcase
Published in Marketplace Apps & Integrations

5 mobile apps for Jira Cloud to boost productivity

  It’s very important to have access to the workflow process from anywhere. Especially if you manage the work of others. There is no difference whether you’re out of office, or drive a ca...

240 views 2 5
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you