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!
Hi Daniel,
I think @Alexey Matveev 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
}
Please 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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Anyone else have any thoughts on what the Condition would be? Should I create a ticket with Adaptavist?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.