Transition Workflow Guard, Who Initiated The Request?


I am creating a state tranisition workflow and for some transitions, I need to guard against certain users being able to change the state of an issue from one value to another. 


So far I have been unable to figure out what in the ctx object identifies the user that is attempting to make the state change. 


Sudo code of what I am trying to do as follows:


Done: {
    guard: function(ctx) {
        if (the user who is trying to change the state is not "UserA") {
            workflow.message('You cannot change this state');
            return false;
       return true;

I know I cannot use ctx.issue.updatedBy because in the guard the issue has not actually changed yet. 

So what can I use in the guard to see what user is attempting to change the state? Basically, the actor of the transition. 


Solved, ctx.currentUser is the value that I need. I could not find it in the autocomplete or documentation. Finally, I found an example that used it. 


Thank you for sharing the solution!


Please sign in to leave a comment.