i want to copy the value of issue description to a customfield. I got following code and need to get description as a variable to use it as value for "def modifiedvalue = "some value".
how do i define this?
Code:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class)
def searchProvider = ComponentAccessor.getComponent(SearchProvider.class)
def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def searchQuery = "project = SSPA" // the JQL query you want to use
def customField = "Some Custom Field" // the name of the custom field to change
def modifiedValue = "Some Value" // the new value
def query = jqlQueryParser.parseQuery(searchQuery)
def results = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter())
results.getIssues().each {documentIssue ->
def issue = issueManager.getIssueObject(documentIssue.id)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def modifiedField = customFieldManager.getCustomFieldObjectsByName(customField)[0]
modifiedField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(modifiedField), modifiedValue),new DefaultIssueChangeHolder())
}
Please try this one;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.event.type.EventDispatchOption;
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class)
def searchProvider = ComponentAccessor.getComponent(SearchProvider.class)
def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def searchQuery = "project = SSPA" // the JQL query you want to use
def customField = "customfield_xxxxx" // the id of the custom field to change
def fieldCF = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(customField);
def query = jqlQueryParser.parseQuery(searchQuery)
def results = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter())
results.getIssues().each {documentIssue ->
def jqlIssue = issueManager.getIssueObject(documentIssue.id)
log.error("Issue: " +jqlIssue.key)
jqlIssue.setCustomFieldValue(fieldCF,jqlIssue.getDescription())
issueManager.updateIssue(user, jqlIssue, EventDispatchOption.DO_NOT_DISPATCH, false)
}
Tansu
Hi Tansu,
it works, thank you very much :)
Alex
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.
If your question is about how to get an issue's description value in groovy, you can use
def descValue = issue.getDescription()
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.