Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,294,223
Community Members
 
Community Events
165
Community Groups

Adding user to a project's role postfunction script works only if executed twice

Fazila Ashraf Community Leader Feb 16, 2019

Hi

I execute the below snippet in the transition postfunction as scriptrunner script to add the actor to the given project's user role.

 

ApplicationUser user = ComponentAccessor.getUserManager().getUserByKey("jira-admin-user")

ComponentAccessor.getJiraAuthenticationContext().setLoggedInUser(user)

def projectManager = ComponentAccessor.getProjectManager()
def projectRoleService = ComponentAccessor.getComponent(ProjectRoleService)
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)


def actors=[fazila]

def project = projectManager.getProjectObjByKey("JIRASUPPORT")

def projectRole = projectRoleManager.getProjectRole("Users")

def errorCollection = new SimpleErrorCollection()


projectRoleService.addActorsToProjectRole(actors,
projectRole,
project,
ProjectRoleActor.USER_ROLE_ACTOR_TYPE,
errorCollection)

log.debug "errorCollection" + errorCollection.toString()

 

It works well in the staging JIRA instance. But when i did the same in production, i have to execute the transition twice to actually get the user account added to the project's role.

The errorcollection is empty for both the execution and there are logs for both the transition execution. The code gets executed with out any error but the first time it just doesnt do the add user to project role action.

When i execute it in script console, once is actually enough.

What could be causing this in the JIRA instance? 

Thanks in advance for the help and insight!

1 answer

Yes. We are facing the exactly the same issue.

 

Any update?

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

255 views 0 6
Join discussion

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