# JSM Cloud - JSM Server / User creation sync

**URL:** <https://community.exalate.com/t/jsm-cloud-jsm-server-user-creation-sync/6316>\
**Category:** General Questions\
**Tags:** cloud-jira\
**Created:** [April 9, 2025, 3:52pm UTC](https://community.exalate.com/t/jsm-cloud-jsm-server-user-creation-sync/6316 "2025-04-09T15:52:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_Bosano](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/martin_bosano/32/482_2.png) [@Martin\_Bosano](https://community.exalate.com/u/Martin_Bosano)\
**Post date:** [April 9, 2025, 3:52pm UTC](https://community.exalate.com/t/jsm-cloud-jsm-server-user-creation-sync/6316/1 "2025-04-09T15:52:52Z")

</div>

Hello

We have a connection with Exalate between a JSM Cloud and a JSM Server.  
When a user creates a ticket in the JSM Cloud we want to pass as a reporter or as a participant to the ticket created in JSM Sever. We have a code to create the user in the connection configuration in the server, in the incoming sync section:

------------------------------/////////  
def localUserForRemoteReporter = userHelper.getByEmail(replica.reporter.email)  
if (localUserForRemoteReporter == null) {  
// create the user if s/he doesn’t exist  
localUserForRemoteReporter = userHelper.createUser(replica.reporter.username,  
“changeme”,  
replica.reporter.email,  
replica.reporter.displayName)  
}  
issue.reporter = localUserForRemoteReporter  
issue.customFields.“Participantes de la solicitud”.value += localUserForRemoteReporter  
------------------------------/////////

I performed some tests and was able to see that performing the following changes to the script fixes the issue:

------------------------------/////////  
def localUserForRemoteReporter = userHelper.getByEmail(replica.reporter.email)  
if (localUserForRemoteReporter == null) {  
// create the user if s/he doesn’t exist  
localUserForRemoteReporter = userHelper.createUser(replica.reporter.displayName,  
“changeme”,  
replica.reporter.email,  
replica.reporter.displayName)  
}  
issue.reporter = localUserForRemoteReporter  
issue.customFields.“Participantes de la solicitud”.value += localUserForRemoteReporter  
------------------------------/////////

The user then was created but has been created as a jira user (with license), not as a portal customer.

Is it possible for him to be created as a portal user, or as a participant, or as a user but without being added to the default groups that give access to the product?

Participants are not being copied to the jira server unless they previously exist as users in jira server.

Thanks in advance

---

<div class="post-metadata">

**Author:** ![Martin\_Bosano](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/martin_bosano/32/482_2.png) [@Martin\_Bosano](https://community.exalate.com/u/Martin_Bosano)\
**Post date:** [April 9, 2025, 3:53pm UTC](https://community.exalate.com/t/jsm-cloud-jsm-server-user-creation-sync/6316/2 "2025-04-09T15:53:44Z")

</div>

Creating this on behalf of [esther.ortega@xeridia.com](mailto:esther.ortega@xeridia.com)

---

<div class="post-metadata">

**Author:** ![Majid](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/majid/32/343_2.png) [@Majid](https://community.exalate.com/u/Majid)\
**Post date:** [April 27, 2025, 2:15pm UTC](https://community.exalate.com/t/jsm-cloud-jsm-server-user-creation-sync/6316/3 "2025-04-27T14:15:03Z")

</div>

Hi,

I believe you should be able to do this, but not with the native createUser() method, but rather by direct interaction with the Jira API. I tried the following (hardcoded values) and it did the trick for me. Hopefully it gives you some ideas:

```auto
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.ProjectManager
import com.atlassian.jira.security.roles.ProjectRoleManager

def username = "customer_email@example.com"
def password = "RandomPassword123!" // Or generate something random
def emailAddress = "customer_email@example.com"
def fullName = "Customer Name"
def projectKey = "SON" // <-- your Service Management project key

def userUtil = ComponentAccessor.userUtil
def userManager = ComponentAccessor.userManager
def groupManager = ComponentAccessor.groupManager
def projectManager = ComponentAccessor.projectManager
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)

def project = projectManager.getProjectByCurrentKey(projectKey)

// Check if user already exists
def existingUser = userManager.getUserByName(username)
def newUser

if (existingUser) {
    log.info "User already exists: ${existingUser.name}"
    newUser = existingUser
} else {
    newUser = userUtil.createUserNoNotification(username, password, emailAddress, fullName)
    log.info "User created: ${newUser.name}"
    
    // Add to 'jira-servicedesk-customers' group
    def customerGroup = groupManager.getGroup("jira-servicedesk-customers")
    if (customerGroup) {
        userUtil.addUserToGroup(customerGroup, newUser)
    }
}

```

Thanks  
Majid

---

<div class="post-metadata">

**Author:** ![Sonal\_Otwani](https://dub1.discourse-cdn.com/flex018/user_avatar/community.exalate.com/sonal_otwani/32/392_2.png) [@Sonal\_Otwani](https://community.exalate.com/u/Sonal_Otwani)\
**Post date:** [June 19, 2025, 6:57am UTC](https://community.exalate.com/t/jsm-cloud-jsm-server-user-creation-sync/6316/5 "2025-06-19T06:57:29Z")

</div>

Hey @Martin_Bosano

Can you please confirm whether the solution provided by @Majid was working as expected or not?

Thanks,  
Sonal
