What I need to do is to move a custom value to a jira built in field. So, I need to move the value in the custom field "Conversation" to the jira's Description field.
Where I'm stuck is how to I set (or update) the description field on an Issue? I see no setter for it and doing this way is not letting me as it's a read only field.
Please tell me that there is a way to update a Jira Issue field...
Here is a snippet of my code:
CustomField cfSource = customFieldManager.getCustomFieldObject("customfield_10100"); for(Issue issue in issues) { String conversation = issue.getCustomFieldValue(cfSource); issue.description = conversation; }
Thanks in advance.
Community moderators have prevented the ability to post new answers.
Hey all -- thanks for your help in pointing me in the right direction. This is my first time delving into the Jira APIs hence first time seeing it all so it's a bit daunting at first. I ended up going with this as a solution (using the IssueService to make the make the updates)
IssueInputParametersImpl inputParameters = new IssueInputParametersImpl(); inputParameters.setDescription(conversation); inputParameters.addCustomFieldValue(sourceCustomField, ""); validateResults = issueService.validateUpdate(user, issue.getId(), inputParameters); if (validateResults.isValid()) { issueService.update(user, validateResults); }
In order to make an update to an issue, you have to first test it via validateUpdate and this returns IssueService.UpdateValidationResult which (if it is valid) you pass it into the IssueService.update call.
I'm sure there are other ways to do this, but this worked for me.
You also asked this on the script runner page... There is more than one way of updating an issue. Using the IssueService will result in a changelog and maybe events being fired, which you normally don't want if just doing maintenance.
Here is a way that doesn't create a changelog entry etc:
import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.ModifiedValue import com.atlassian.jira.issue.util.DefaultIssueChangeHolder def componentManager = ComponentManager.getInstance() def customFieldManager = componentManager.getCustomFieldManager() def tgtField = customFieldManager.getCustomFieldObjects(issue).find {it.name == "Name of custom field"} def changeHolder = new DefaultIssueChangeHolder(); tgtField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(tgtField), "some new value"),changeHolder);
Bah, I didn't read your question properly. Go with Jobin's suggestion.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use IssueService.
You can find examples at https://developer.atlassian.com/display/JIRADEV/Plugin+Tutorial+-+JIRA+Issue+CRUD+and+Search
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.