Forums

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

Create Jira user without sending email from Java / Script runner

Jens Kisters //SeibertSolutions
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.
April 30, 2018

Hello,

i cant manage to suppress the "Account created" mail that is sent when i execute this code:

 

import com.atlassian.jira.bc.user.UserService;
import com.atlassian.jira.component.ComponentAccessor;

UserService userService = ComponentAccessor.getComponent(UserService.class);
UserService.CreateUserRequest createUserRequest = UserService.CreateUserRequest
.withUserDetails("admin", "newusername", "", "email@email.com", "Firstname Lastname")
.withNoApplicationAccess();
createUserRequest.sendNotification(false);
UserService.CreateUserValidationResult result = userService.validateCreateUser(createUserRequest);

Thanks in advance, Internet <3

2 answers

1 accepted

0 votes
Answer accepted
Jens Kisters //SeibertSolutions
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.
May 2, 2018

ok i got it (sendNotification returns a CreateUserRequest):

 

UserService.CreateUserRequest createUserRequest = UserService.CreateUserRequest
.withUserDetails(runAsJuser, username, "", mailAdressString, issue.getSummary())
.withNoApplicationAccess()
.sendNotification(false)
;

UserService.CreateUserValidationResult result = userService.validateCreateUser(createUserRequest);
0 votes
Edwin Kyalangalilwa
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.
May 1, 2018

Hi Jens,

Use the sendNotification method

Specify whether a notification should be sent when the new user has successfully been created.

sendNotification

Jens Kisters //SeibertSolutions
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.
May 2, 2018

Hi Edwin,

thanks for your reply.

I tried it like this but a mail was sent out:

 

UserService.CreateUserRequest createUserRequest = UserService.CreateUserRequest
.withUserDetails(runAsJuser, username, "", mailAdressString, issue.getSummary())
.withNoApplicationAccess()
;

createUserRequest.sendNotification(false);
UserService.CreateUserValidationResult result = userService.validateCreateUser(createUserRequest);

Any Idea whats going on?

Jens Kisters //SeibertSolutions
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.
May 2, 2018

ok i got it (see below)

Thanks!

Suggest an answer

Log in or Sign up to answer