hello team
I would like to filfil the system field assignee from a custom field , type of custom field = User picker . so i find trhis code but it work here , but when i put it in a post function , the assignee does not change .
i need your help.
Regards
Hi,
This snippet should work fine :
def customFieldManager = ComponentAccessor.getCustomFieldManager()
//Jira User picker ID
int userPickerId = 10013
def cfUserPicker = customFieldManager.getCustomFieldObject(userPickerId)
def cfUserPickerValue = issue.getCustomFieldValue(cfUserPicker)
issue.setAssignee(cfUserPickerValue)
If it does not, add some logs to check where it is failing.
Antoine
hi @Antoine Berry .
Thank you , yes there are always the same problem , i make some log but it return coorect result , but when i go to the issue there are always the same user assignee , it does not change .
i can not understand what's the problem , also there are a warn appear , in the picture .
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Don't worry about the WARN, it shows because we did not specify the type of cfUserPickerValue. But it is groovy so it is not a problem, as you can see it executes correctly.
Did the assignee change ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Weird, this is working fine with me.
Can you add
def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService)
issue.store()
issueIndexingService.reIndex(issue)
at the end ? See if that helped and provide a screenshot again ?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
there are another problem appear
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.user.ApplicationUser
def issueManager = ComponentAccessor.issueManager
def customFieldManager = ComponentAccessor.customFieldManager
import com.atlassian.jira.user.util.UserManager
def issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("AB-1");
//Jira User picker ID
int userPickerId = 10013
def cfUserPicker = customFieldManager.getCustomFieldObject(userPickerId)
log.warn("customfield " + cfUserPicker )
def cfUserPickerValue = issue.getCustomFieldValue(cfUserPicker)
log.warn("current assignee == " + issue.assignee )
issue.setAssignee(cfUserPickerValue)
log.warn(" new assigneee = " + cfUserPickerValue )
def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService)
issue.store()
issueIndexingService.reIndex(issue)
regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ah, no big deal, just an import missing. Try
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.index.IssueIndexingService
def issueManager = ComponentAccessor.issueManager
def customFieldManager = ComponentAccessor.customFieldManager
import com.atlassian.jira.user.util.UserManager
def issue = ComponentAccessor.getIssueManager().getIssueByCurrentKey("AB-1");
//Jira User picker ID
int userPickerId = 10013
def cfUserPicker = customFieldManager.getCustomFieldObject(userPickerId)
log.warn("customfield " + cfUserPicker )
def cfUserPickerValue = issue.getCustomFieldValue(cfUserPicker)
log.warn("current assignee == " + issue.assignee )
issue.setAssignee(cfUserPickerValue)
def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService)
issue.store()
issueIndexingService.reIndex(issue)
log.warn(" new assigneee = " + issue.assignee )
I added the value of the assignee at the end so we can see if it updated successfully.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Karim Belhadj
Try this:
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.event.type.EventDispatchOption;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.user.ApplicationUser;
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
def issue = ComponentAccessor.issueManager.getIssueByCurrentKey('AB-1');
def cField = customFieldManager.getCustomFieldObjectByName("Your cf name"); // You can use ID
ApplicationUser user = issue.getCustomFieldValue(cField) as ApplicationUser;
issue.setAssignee(user);
ComponentAccessor.getIssueManager().updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false);
Give me an answer about the result!
Good luck!
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You want to fill Assignee from a custom user picker field, when a specific Transition/status is reached (i.e. Task is opened, set to V&V, ...)?
there are several addons on Marketplace which help you to do this.
a free one is for example https://marketplace.atlassian.com/apps/1211836/automation-lite-for-jira?hosting=server&tab=overview
https://docs.automationforjira.com/getting-started/actions.html#add-service-desk-customer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Alexander Pappert i need this with a sample code script runner , i do not ask for addon , thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.