Please some one help me on my below request.
I'm using field " Story Points" on issue create/view/edit form.
I have writen script runner listener to copy value from "Story Point" to "Points" field , whenenver "Story Point" is edited, it's updating "Points" field value as expected .But problem is that when i try to generate JIRA Version report in scrum board using "Points" value as estimation then updated value treated as original date only not taking updated date to drawing version report.
Here is my scriptrunner lister code
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.component.ComponentAccessor
def issue = event.issue as Issue
def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Story Points");
def sp = issue.getCustomFieldValue( cf ) ?: 0
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def tgtField = customFieldManager.getCustomFieldObjects(event.issue).find {it.name == "Points"}
def changeHolder = new DefaultIssueChangeHolder()
tgtField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(tgtField),(double)sp),changeHolder)
Is there any way to update issue change history along with "Points" field value ?
Please help me.
You may simply need to use the IssueService to update the issue in order to make sure that all the normal business logic events are getting fired properly. Make sure to put a good condition on your listener so that you don't end up in an infinite loop where the listener keeps triggering itself.
Starting from your script, something like this should work:
import com.atlassian.jira.issue.Issue import com.atlassian.jira.component.ComponentAccessor def issue = event.issue as Issue def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Story Points"); def sp = issue.getCustomFieldValue( cf ) ?: 0 def customFieldManager = ComponentAccessor.getCustomFieldManager() def tgtField = customFieldManager.getCustomFieldObjects(issue).find {it.name == "Points"} def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() def issueService = ComponentAccessor.getIssueService() def issueInputParameters = issueService.newIssueInputParameters() issueInputParameters.with { addCustomFieldValue(tgtField.idAsLong, sp.toString()) } def updateValidationResult = issueService.validateUpdate(currentUser, issue.id, issueInputParameters) if (updateValidationResult.isValid()) { issueService.update(currentUser, updateValidationResult) }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.