You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Hello,
when moving operations, the sprint field is not emptied. This causes the operations with wrong sprint on other boards. We have filter related boards. Is there a way I can clear the sprint field on the move? Is it possible with Scriptrunner? If yes how? And how can I use Scriptrunner to clear Cutomfields.
Here is sample code for a Move Issue event listener:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.UpdateIssueRequest
// optionally, check from/to project and conditionally execute...
def issueManager = ComponentAccessor.getComponent(IssueManager)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def sprintCf = customFieldManager.getCustomFieldObjectByName("Sprint")
def user = event.user
def issue = issueManager.getIssueObject(event.issue.id)
issue.setCustomFieldValue(sprintCf, null)
def updateIssueRequest = UpdateIssueRequest.builder().
eventDispatchOption(EventDispatchOption.DO_NOT_DISPATCH).
historyMetadata(null)
issueManager.updateIssue(event.user, issue, updateIssueRequest.build())
I have created a CustomListener and inserted the sample code. It worked. :-) There is also a possibility when cloning issues
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, it worked, because I tested it ;-) An upvote would be nice!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Which event needs to be trapped so that it can work when cloning? Thank yo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's a more complicated question... see https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-detect-if-an-issue-is-a-clone-in-a-listener-at/qaq-p/562675. If you are on jira 7.5 you could do it on IssueLinkCreated and check if it's the cloners link I guess.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Moving an issue tries to retain as much of the issue as the target project allows for, and as Sprint is a global field, it's not going to clear it.
You are right you can do it with ScriptRunner - a listener could be scripted to catch "issue moved", check you want to lose the sprint and clear it (and other fields) by setting them to "null".
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.