User is not added to group via custom plugin code in JIRA


We have build a custom plugin for JIRA. We want to add user to group using JIRA API methods. Previously we were using JIRA v6.4.12 but now we have upgraded to JIRA v7.2.9.

The code we are using is-


UserManager userManager = ComponentAccessor.getComponent(UserManager.class);
dashboardUser = userManager.getUserByName(project.getLeadUserName());
GroupManager groupManager = ComponentAccessor.getComponent(GroupManager.class);
Group templateDashboardGroup = groupManager.getGroup(ServerConstant.TEMPLATE_GROUP);

UserUtil userUtil = ComponentAccessor.getComponent(UserUtil.class); userUtil.addUserToGroup(templateDashboardGroup, dashboardUser); OR   GroupManager groupManager  = ComponentAccessor.getComponent(GroupManager .class); groupManager.addUserToGroup(dashboardUser, templateDashboardGroup);



After this I am checking if user is added successfully in group or not via-



Boolean b = groupManager.isUserInGroup(dashboardUser, templateDashboardGroup);

Here I am getting the result 'b' as false.

But when I am checking via UI in user management section, the user gets added to the group. Similarly on checking the database table, the user is added to the group.

Please help me find what exactly is the issue. If the user is getting reflected in the group on front-end and database table, why 'isUserInGroup' method is returning false.



0 answers

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,755 views 11 18
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot