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.
Thanks!
Hello,
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 :(.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
a.actionId
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Discover how Atlassian is revolutionizing service management with cutting-edge solutions for AI-powered support, HR Service Management, or DevOps connectivity.
Register here ⬇️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.