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

Workflow transition post function ScriptRunner condition help

Hey everyone!

Long time lurker, first time poster ;)

Trying to add a post function to a workflow transition (Script Post-Function -> "Fires an event when condition is true"), and I need your help with writing up a condition that will check to see if a comment was added during the transition. If that condition is met, it'll fire the event.

Any info/direction would be greatly appreciated!

3 answers

1 accepted

2 votes
Answer accepted

Hi Daniel,

I think @Alexey_Matveev__cPrime_ essentially gave you the correct answer, but you just need to apply it as a post-function that fires a condition when true and not strictly as a validator. For example, your condition would be this:

if (transientVars.get("comment")) {
log.debug("User has entered a comment on the transition screen.")
return true

 Screen Shot 2017-11-13 at 4.00.38 PM.pngPlease note: just ignore the static type checking error, as the script will still work.

I have tested it successfully and can see it's working from the output in the logs:

[scriptrunner.jira.workflow.ScriptWorkflowFunction] User has entered a comment on the transition screen.
[jira.workflow.postfunctions.FireEventWhen] Raising event: 2

Perfect, that's exactly what I was looking for, and confirmed working on our end as well! Thank you so much, Joshua, you're a life saver!! :D

1 vote


I guess you can not achieve it with a post function. You can check if a comment was added in a validator. The code for the validator would be something like this:

if (transientVars.get("comment")) { ... }

What is your business requirement? Maybe there is another solution

Thank you for following up, Alexey! From what I understand, if I set up a validator for the transition (to check if a comment was added), when no comment is added, it will not complete the transition - is that correct? If that's the case, then a validator may not be what I'm looking for.

To explain, the business requirement is limiting the number/type of notifications that go out to our assignees, as right now, any event we set to the transition (i.e. Issue Commented, Generic Event, etc.) will fire off a notification regardless of whether or not a comment was added. What we want is to only send notifications for specific transitions that have a comment field attached to their screens when a comment is added.

Alternatively, I guess it would also work if we could remove the comment field from those transitions, but from everything I've tried (both through the Screens/Screen Schemes section and through the properties for the transition itself), that doesn't appear to be possible. Ideally, it would be possible to do what I mentioned in my original post above about finding a condition in the post-function, so hopefully someone has an idea of how that can be done :)

Anyone else have any thoughts on what the Condition would be? Should I create a ticket with Adaptavist?

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Service Desk

How has Jira Service Desk increased productivity in your org?

Hi Jira Service Desk community, Atlassian is on a mission to unleash the potential of all teams, and we know that tools are just one piece of that puzzle. With Jira Service Desk, we have productiv...

171 views 0 3
Join discussion

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