Hello All,
I want to set a value for a custom field.
I try it to do it with a text field but didn't work...
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObjectByName("testgroovy2")
issue.setCustomFieldValue(cf,"Its Works")
How can I fixed it?
if I want to do it with a select user field....what I need to add?
Thank you all!
Community moderators have prevented the ability to post new answers.
Hello @Aitor Bermejo Cacho
You also need to save changes with IssueManager, like this
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManafer = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def cf = customFieldManager.getCustomFieldObjectByName("testgroovy2")
def userCf = customFieldManager.getCustomFieldObjectByName("user picker")
issue.setCustomFieldValue(cf,"Its Works")
issue.setCustomFieldValue(userCf, user)
issueManafer.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
And to set User Picker, you need to pass ApplicationUser object.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If it user picker, you need ApplicationUser object. Like in my example it sets currentUser in "user picker" field.
If you need some other user, use UserManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManafer = ComponentAccessor.getIssueManager()
def userManager = ComponentAccessor.getUserManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def userToSet = userManager.getUserByKey("userkey")
def userCf = customFieldManager.getCustomFieldObjectByName("user picker")
issue.setCustomFieldValue(userCf, userToSet)
issueManafer.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @YogeshRanjit
I think this is a typical error of beginer...
If you are doing the code in Console, please define one issue and use it.
If you are doing the code in postfunction or listened only is necessary to declare.
//Test para Console
def issueKey = "IESD-14862"
def issueManager = ComponentAccessor.getIssueManager()
def issue = issueManager.getIssueObject(issueKey)
//def issue = issue as Issue
log.info("issue: "+ issue)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
OR
import com.atlassian.jira.user.util.UserManager
@StandardModule IssueManager issueManager
Issue issue = issueManager.getIssueByCurrentKey("ISSUEKEY-00000")
some code...
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.
can some one help me on this I want to multiple 3 different field values and display them on 4th field
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.