Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

I want to automatically register a component representative in the user selector field

Edited

Hello
I'm going to use Scriptrunner's post function function.
When the status changes after the ticket is issued, I want to automatically register the user with the user picker by putting the person in charge of the component in the user picker.

Is this possible? below is the script.

 

package com.onresolve.jira.groovy.test.scriptfields.scripts
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.atlassian.jira.user.ApplicationUser

def log = Logger.getLogger("com.acme.curvc")

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def componentManager = ComponentAccessor.projectComponentManager

def userCf = customFieldManager.getCustomFieldObject(12823L) // Developer
def component = issue.componentObjects.toList()
def leadUser = component.componentLead.username

log.debug("test : " + leadUser[0])


if(component.size() == 1){
issue.setCustomFieldValue(userCf, leadUser[0])
}
else if(component.size() > 1){
issue.setCustomFieldValue(userCf, leadUser[0])
}
else{
return "none component"

 

 

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Dec 31, 2021

This is absolutely possible, but you have to put it early in the post functions (before "Creates the issue originally").

Try it this way instead:

package com.onresolve.jira.groovy.test.scriptfields.scripts
import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.atlassian.jira.user.ApplicationUser

def log = Logger.getLogger("com.acme.curvc")

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def componentManager = ComponentAccessor.projectComponentManager

def userCf = customFieldManager.getCustomFieldObject(12823L) // Developer
def components = issue.components


if(components){
issue.setCustomFieldValue(userCf, components.first().componentLead)
if(components.size() == 1){
log.info "Single component selected: applied ${components.first().componentLead.name} to Developer field"
} else {
log.info "Multiple component selected: applied ${components.first().componentLead.name} to Developer field (lead for first component)"
}
}
log.info "No component selected"
}

@Peter-Dave Sheehan Thank you for your reply Peter.

finally I resolved it.

TAGS
AUG Leaders

Atlassian Community Events