Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Scriptrunner to add user to group in Jira Cloud.

Aisha M
Contributor
July 10, 2026

I have a script which gets the reporter ID from a service desk form and adds the user to a specific group.

I used the exact same syntax provided in the Adaptavist documentation, yet it doe snot work:  https://docs.adaptavist.com/sr4jc/latest/hapi/work-with-groups#add-users-to-a-group

 

def group = Groups.getByName('jira-developers')

// user can be added to the group by their account id
group.add('user_account_id')

 

Any help on how to fix this ?

Thank you

2 answers

Suggest an answer

Log in or Sign up to answer
0 votes
Joseph Chung Yin
Community Champion
July 10, 2026

@Aisha M 

Great suggestion provided by @Germán Morales .  Since this is related to Scriptrunner add-on, you can also contact the vendor directly for additional technical support.

Lastly, what is the purpose of your group?  Is this group for the portal users (reporters) only?

Please advise.

Best, Joseph

0 votes
Germán Morales
Atlassian Partner
July 10, 2026

Hi @Aisha M , the syntax you copied is correct. The catch is that group.add(accountId) returns a boolean instead of throwing on failure, so a call that doesn't work fails completely silently unless you capture that return value.

  • Assign the result of group.add(accountId) to a variable and log it. If it comes back false, the account ID wasn't accepted, either because it isn't a genuine account ID, or because the user is already a member of the group.
  • If Groups.getByName('jira-developers') failed to find the group, calling add on that result throws an error rather than failing quietly, so if nothing is being thrown, the group lookup is fine and the account ID is where to look.
  • Print the value your script pulls from the reporter right before the add call and compare it against that user's real account ID in the Jira Cloud people directory. Passing the reporter's display name, email, or issue key instead of the account ID looks identical to the documented example but adds nothing.

Once the logged return value comes back true, the group membership has actually been written.

TAGS
AUG Leaders

Atlassian Community Events