How to retrieve users use for transition permissions check in condition?

Hi,

I am basically trying to execute a transition as if it was execute by a user different from the one currently logged in.

Considering the following:

  • The current logged in user is "userA"
  • "userA" modifies a field which via a listener executes the following automatic transition:

    def UserManager userManager = ComponentAccessor.getUserManager()
    ApplicationUser user = userManager.getUserByName("jira")
    
    IssueService.TransitionValidationResult transitionValidationResult = issueService.validateTransition(
            user,issue.id, actionId,new IssueInputParametersImpl([:])
    )
    
    //if(true)
    if(! transitionValidationResult.errorCollection.hasAnyErrors())
    {
        log.debug("Transition Successful")
        issueService.transition(user,transitionValidationResult)
        return true
    }
    else
    {
        log.debug("Transition Error: ${transitionValidationResult.errorCollection.toString()}")
        return false
    }

    Please note that he transition is called using the user "jira" rather than the currenty logged in user ("userA")


Now, in the condition of the transition corresponding to "actionid"  I would like to be able to know which was the user used as parameter of validateTransition(). Referring to my example, this would give as a result the user "jira".

If I use either

((WorkflowContext) transientVars.get("context")).getCaller();

or

ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

I get as result the user "userA" not "jira"

 

Thanks.

4 answers

This widget could not be displayed.

I don't really follow here could you explain a bit more?

This widget could not be displayed.

Niclas Sandström [Riada] I have expanded the question. Hope now it is clear.

This widget could not be displayed.

Hi! 

May I know did you find a solution for your question? 

This widget could not be displayed.

You can use 

ComponentAccessor.getJiraAuthenticationContext().setLoggedInUser(user)

before issueService.validateTransition(...)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

421 views 3 17
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you