Check if user is in project role using JQuery/Javascript

Declan Murphy July 30, 2015

I need to check to see if a user is in a particular project role using JQuery on the View Issue screen. Is there a way I can do this using the REST API or something similar?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2015

Actually, you probably can.

/rest/api/2/project/{projectIdOrKey}/role should get you all roles in a project.

/rest/api/2/project/{projectIdOrKey}/role/{id} should get you the actors in the given role.

You can check if the user is part of the output from the second query. I haven't tried it myself but worth checking.

Declan Murphy July 30, 2015

Thanks for the help. This is definitely on the track of what I'm looking for. On the J-Tricks site, I found the following: // Get a list of groups function getGroups(user){ var groups; AJS.$.ajax({ url: "/rest/api/2/user?username="+user+"&expand=groups", type: 'get', dataType: 'json', async: false, success: function(data) { groups = data.groups.items; } }); console.log("Groups : " + groups); return groups; } // Check to see if user is in group function isUserInGroup(user, group){ var groups = getGroups(user); for (i = 0; i < groups.length; i++){ if (groups[i].name == group){ return true; } } return false; } How would I go about modifying these to instead get the roles a user is a member of using the rest urls above?

0 votes
Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2015

Not with the standard JIRA REST api. You need to create custom JIRA REST plugin for this.

TAGS
AUG Leaders

Atlassian Community Events