Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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 Rule Actor of a project automation rule in Scriptrunner custom script validator


I'm using automation rule (Automation for JIRA addon) in my project. Now I need to get the Rule Actor of my automation rule in scriptrunner custom script validator. This is because I do not want to run the validation when the rule actor is on my name.

I tried using the currentUser in my script. But this always returns the current login user and not the Rule Actor.

Is there a solution for this problem?

2 answers

0 votes

Hey there,

I think you should be able to use:


Hope that helps!


Mark C 

@Mark Chaimungkalanont , Thanks for the reply.

I am getting the attached error in my script validator using {{}CustomScriptValidator-Error.png

The correct binding variable to use with ScriptRunner is currentUser (see here for more).

For example:

def ruleActor = currentUser

@Gareth Cantrell, currentUser returns JIRA logged-in user. But not the Rule Actor of my automation user.

From the scriptrunner documentation, I could see the below code. When I try to test this code in my scriptrunner custom script validator, I get the error because ruleContext is not defined.

log.warn ("Initiator of the action was... " + ruleContext.renderSmartValues('{{initiator}}'))

How can I import ruleContext?

@KL Kumar you are trying to use a smart value rather than the script binding variable.

The smart value {{initiator}} is specific to the automation rule and returns the user who initiated the rule, and is not necessarily the rule actor!

ScriptRunner, on the other hand, binds the rule actor to the currentUser variable in the script:

log.warn ("Rule actor is... " + currentUser)

Additionally, if you're getting an error when trying to use ruleContext, you are most likely using an older version of either ScriptRunner or Automation for Jira.

If you're using the latest versions of both apps, the following code should work to show the difference (using a manually triggered rule where the rule actor and the initiating user are different):

log.warn ("Rule actor is... " + currentUser + ", Rule initiating user is... " + ruleContext.renderSmartValues('{{initiator}}') )

@Gareth Cantrell , Thanks for the reply.

I upgraded both the plugins to latest.

  • Scriptrunner for Jira - 6.17.0
  • Automation for Jira - 7.2.4

Still I get the error as undefined. Am I still making mistake anywhere!error.png

@KL Kumar I got confused by your mention of Automation for Jira in your original question. I assumed you were trying to create an automation rule, rather than a workflow validation.

Automation for Jira rules cannot be used within a workflow. They can respond to workflow events after the fact, but cannot be used to affect the outcome of a transition.

To get the user who initiated a workflow transition in a ScriptRunner scripted validation, you would need to use code similar to the following:

import com.atlassian.jira.component.ComponentAccessor

log.warn "Current user is ... " + ComponentAccessor.userManager.getUserByKey(transientVars.userKey)

What exactly are you trying to accomplish with automation rules?

@Gareth Cantrell

transientVars.userKey returns the user who initiated the workflow (ideally it is the person who logged into JIRA). So this isn't working for my scenario.

My project has an automation with rule actor configured as "" (automation user). My requirement here is to skip the scriptrunner script validation when the automation rule actor is "". So that's the reason I am trying to get the rule actor user in my scriptrunner script validation.

The script is something like...

if (currentUser == "") {   // unfortunately this always returns JIRA login user

     // skip validation.

} else {

    // proceed with validation


@KL Kumar Automation for Jira will set the current user to the user defined as the rule actor when initiating a workflow transition.

Here's what I did:

  1. Create a new user called Rule Actor with username
    Screenshot 2021-01-27 at 14.12.17.png
  2. Created a manually triggered rule to transition an issue to In Progress, and set the rule actor to the Rule Actor user.
    Screenshot 2021-01-27 at 14.12.57.png
  3. Created the following validation on the "In Progress" transition.
    Screenshot 2021-01-27 at 14.17.11.png
  4. Triggered the automation on the issue from the "More" menu.
  5. Transitioned the issue to In Progress as the admin user.
  6. Examined the atlassian-jira.log file:
    2021-01-27 14:15:38,563+0000 http-nio-8080-exec-3 WARN 855x4063x1 wkh6pz 0:0:0:0:0:0:0:1 /rest/cb-automation/latest/project/10000/rule/149/execute/MAPP-9 [c.o.scriptrunner.runner.ScriptBindingsManager] Workflow transition initiated by

    2021-01-27 14:15:38,564+0000 http-nio-8080-exec-3 WARN 855x4063x1 wkh6pz 0:0:0:0:0:0:0:1 /rest/cb-automation/latest/project/10000/rule/149/execute/MAPP-9 [c.o.scriptrunner.runner.ScriptBindingsManager] Transition initiated by automation rule, skipping validation...

    2021-01-27 14:15:41,569+0000 http-nio-8080-exec-6 WARN admin 855x4073x1 wkh6pz 0:0:0:0:0:0:0:1 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] Workflow transition initiated by admin

    2021-01-27 14:15:41,571+0000 http-nio-8080-exec-6 WARN admin 855x4073x1 wkh6pz 0:0:0:0:0:0:0:1 /secure/WorkflowUIDispatcher.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] Transition initiated by normal user

One thing to note is that the workflow is only aware of the user who initiated the transition. It is not possible to determine which automation rule initiated the transition.

@Gareth Cantrell Thank you for the explanation.

The only difference I am seeing here is - in my case I have the automation which is triggered automatically when the transition happens. So this way, I am getting the currentUser as logged-in user.

When you tried with manual trigger, you got the

So it seems that there's no possibility to get the rule actor in scriptrunner script validator when the automation rule is triggered automatically.

Thanks a lot for the help!

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