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
Accepted answer

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
Asked Dec 06, 2018 in Jira Service Desk

Looking for teams who switched from email to Jira Service Desk

The Jira Service Desk marketing team is working on a guide to help new Atlassian customers switch from email to JSD and we'd love to hear from you! Please share: - What made you realize that i...

262 views 1 7
View question

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