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
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Trying to populate a date customfield from another date customfield on CustomFieldUpdated Event. Copied some of this code from other posts. I am getting variable [ issue ] not declared error.
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.event.issue.field.CustomFieldUpdatedEvent
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
//def issue = event.issue
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
issue.setCustomFieldValue(
customFieldManager.getCustomFieldObjectByName("Audit Original Testing Due Date")
, customFieldManager.getCustomFieldObjectByName("Audit Testing Due Date"))
Tried this earlier. No errors on the inline script editor, but the other field also does not get updated. Code below:
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
import com.atlassian.jira.issue.CustomFieldManager
def issue = event.issue as Issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def tgtField = customFieldManager.getCustomFieldObjects(event.issue).find {it.name == "Audit Original Testing Due Date"}
def changeHolder = new DefaultIssueChangeHolder()
tgtField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(tgtField), customFieldManager.getCustomFieldObjectByName("Audit Testing Due Date")),changeHolder)
There are no errors in the log
Have you tried getting the target field by using
def tgtField = customFieldManager.getCustomFieldObjectByName("Audit Original Testing Due Date")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the suggestion. Just tried this. No errors in log, but the code has not been called by the listener for CustomFieldUpdated Event
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi when I try with event.issue as Issue I'm getting static type checking variable event undeclared.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Replace //def issue = event.issue with
def issue = event.issue as Issue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, forgot to mention I tried that earlier. The error I get with "def issue = event.issue as Issue" is "Cannot find matching method"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You cannot use setCustomFieldValue when running it as a listener. In a listener you need to use updateValue, like this:
textCf2.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(textCf2), myval),changeHolder)
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.