Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Need value of automation rule initiator in scriptrunner script

Tom Hudgins
Contributor
December 15, 2020

Hi,

I'm using Automation for Jira to run a Scriptrunner script. I need the value of the "initiator" of the rule in my script and I don't see a way to get it. One of the binding variables is currentUser but that is the Actor defined in the rule, not the person who actually triggered the automation rule. 

Ultimately, I'm trying to send an email to the initiator. I can use the Send Email action and put "Initiator" in the To field and that works but I need to do some funky processing to build the body of the email - hence the need for a script to actually send the email. I can build and send an email in a script but I don't have the initiator to send it to. 

(Man, I really wish we could pass values to, and get values back from, scripts in automation rules.) Anyway, is there a solution for this problem?

Thanks 

4 answers

1 accepted

0 votes
Answer accepted
Tom Hudgins
Contributor
December 17, 2020

So, it turns out that in version 6.16 of Scriptrunner, they added initiator as a binding variable. 

Interestingly, they also deprecated errorCollection and gave us addMessage() and addError().

0 votes
Angel Ferreira
Contributor
December 19, 2023

For me "initiator.username" works.

0 votes
Aron Gombas _Midori_
Community Champion
December 15, 2020

I'm 80% sure that the smart values are not populated as binding variables. To be 100% sure, ask Adaptavist, developers of ScriptRunner.

(Some weeks ago we tried the same thing that you're trying, and couldn't find an answer.)

Tom Hudgins
Contributor
December 15, 2020

Thanks,

Yes, I did post a question to Adaptavist but figured I'd check here as well - they often refer me to here when they don't have a solution.

I'm pretty pleased with the solution of using the web request action to interact with a Scriptrunner script described in my previous response above. We have a service account that I'm using to authenticate so that solves that problem (mostly).

Tom

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 15, 2020

Hi @Tom Hudgins 

Are these the smart values you need for the Initiator who triggered the rule?

{{initiator.displayName}}
{{initiator.emailAddress}}

Best regards,

Bill

Tom Hudgins
Contributor
December 15, 2020

Hi Bill,

Those are the smart values but I need access to them in a Scriptrunner script - not in the automation rule itself. I basically need some way to pass them to the script.

I do have a kind of workaround for this - passing values to and from a script in an automation rule. I'm playing around with using the Send Web Request action to talk to a Scriptrunner REST endpoint. I can pass data to it in the REST call and get data back in the {{webhookResponse.body}} smart value. 

The only small snag in this approach is the need to bake authentication information in the REST call. 

Tom

Like Martin Cleaver likes this
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 15, 2020

Gotcha... You may want to search the developer forum to see if someone has solved this there: https://community.developer.atlassian.com/

Like Антон likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.11
TAGS
AUG Leaders

Atlassian Community Events