Groovy script to update value to custom field with value of current user
This should cover most of the code you need, although you haven't told us where it will be running, which may adjust what you do and how you get the current user.
https://library.adaptavist.com/entity/update-the-value-of-a-custom-field-in-jira
Thanks Nic for the feedback. I'm planning to use it as a workflow post function
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, from memory, the current user is ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
That might have changed for Jira 7, it's been a while since I needed it in a post-function
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Nic for the reply.
above returns "username(username)". how can I get just username?
May I know the function to get current issue id (JIRA 7)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
in simply, I need to change value for current issue, not for the given ticket id in below script
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.label.Label
def issueManager = ComponentAccessor.getIssueManager()
MutableIssue issue = issueManager.getIssueByCurrentKey("JRA-1")
def user = issue.getReporter()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
//How to set a text field
def stringValue = "This value goes in a text field"
def myTextField = customFieldManager.getCustomFieldObject("textFieldId")
issue.setCustomFieldValue(myTextField, stringValue)
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.