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

Get current workflow transition ID scriptrunner

I need to get the workflow transition ID that the currently logged-in user is trying to trigger from JIRA in a script using scriptrunner.


I tried using transientVars["actionId"] but it's not a valid option when running the script from a file, unfortunately. 

I can't really find a lot on this on how to achieve this.

What I need is just the ID, not the name or linked steps or potential next transitions, but the one that the user is triggering from JIRA.


1 answer

1 accepted

0 votes
Answer accepted


I've tested it both from inline function and from file and it works alright.

Can you provide a little bit more context?

Hello @Ilya_Turov , you are right, I made some additional checks this morning and it does work, but not when you're trying to enclose your entire code in a class. Do you know of any limitations that Scriptrunner has when running class file from a file on the server? I am trying to understand what I am doing wrong, right now :(.

I would say, that since transientVars is a binding variable, and postfunction is a class itself, you can't use it only in a "main context" or something.

If you want to use it in a class, guess you would need to add it to it's constructor like this:

class test {
def actionId
test(transientVars) {
actionId = transientVars["actionId"]
def a = new test(transientVars)

Thank you, you are correct! This has helped me quite a lot. @Ilya_Turov Just one more question: I want to make this re-usable from a CRON in JIRA. If I get rid of the class and arrange the code in methods only, do you think I will run into problems then because I no longer have a class? The Systems part of JIRA is completely separate from scriptrunner and it will not run through a post-function. Thanks!

Yeah, pretty sure there's no binding transientVars for services (basically, it's same thing you can run from script console). So you won't be able to execute same piece of code via postfunction and via CRON.

If it's something really large you want to reuse, you can try using concept of script roots, creating separate class, using it in both postfunction and CRON service, but having different logic in main parts of those two scripts (eg having some transientVars stuff in postfunction, but not in CRON).

Thank you so much! @Ilya_Turov 

Suggest an answer

Log in or Sign up to answer

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