Forums

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

How do I get the activating user in a jira cloud scriptrunner post function (The transitioning user)

Robert W March 28, 2022

I need to take some action in a workflow transition on Jira cloud and It depends on the user.

How do I get the transitioning user (who triggered the post function) in a script runner post function?

1 answer

0 votes
Levente Farkas
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 24, 2025

You configure the post-function to run as the initiating user, then in the function you can call

def result = get('/rest/api/3/myself').asObject(Map)

to get the identity of the initiator. However, if you do this, your script might not be able to do its job due to lack of permissions.

The hackish solution to this is to add another "trigger" transition (from the status on which you had the initial post function, to the same status - self loop transition), which you set to run as the initiating user, and from which you store the caller user's identity on the ticket and then programmatically invoke the real transition. Then you mark the transition that does the real work to run as the Scriptrunner add-on. Finally, in the post function that does the real work you will have the initiating user in a custom field of the ticket.

Keep in mind that self-loop transitions will not show under the Transitions and statuses dropdown but under the Automations one (the next one to right)

The only slight problem left is that you now need to hide the transition that does the real work from the regular users. Restrict it to Jira admins?

Or just bite the bullet, run the post function as the initiating user, then call the endpoints that the initiating user cannot call by authenticating as some user that has the right permissions.

Untitled.jpg

Suggest an answer

Log in or Sign up to answer