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.
Hi,
i have a script (made with scriptrunner) in Jira. This script works only when new issue is created. Script takes fields values from epic and copy to the story/task ... but this script working also when user change field than i need condition to script dont do anything with a certaint fields when this fields has been set by user when user is creating a issue.
I have conditions like this if (epic != null) {
if (field_team != null) {
Is posible to make another condition to check if user set the value (in creating screen) and when set dont do anything?
Can someone please help me?
ok i have a solution >
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.Issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManager = ComponentAccessor.getIssueManager()
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def field_epicLink = customFieldManager.getCustomFieldObject(10001)
def epic = issue.getCustomFieldValue(field_epicLink) as Issue
def field_team = customFieldManager.getCustomFieldObject(10300)
def field_productArea = customFieldManager.getCustomFieldObject(10502)
def team = issue.getCustomFieldValue(field_team)
def productArea = issue.getCustomFieldValue(field_productArea)
if (epic != null) {
if (team == null){
if (field_team != null) {
def value_team = epic.getCustomFieldValue(field_team)
issue.setCustomFieldValue(field_team, value_team)
}
}
if (productArea == null){
if (field_productArea != null){
def value_productArea = epic.getCustomFieldValue(field_productArea)
issue.setCustomFieldValue(field_productArea, value_productArea)
}
}
issueManager.updateIssue(currentUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
}
Thanks everyone for help
This is the code >>> Is posible to make another condition to check if user set the value (in creating screen) and when set dont do anything?
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.Issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def issueManager = ComponentAccessor.getIssueManager()
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def field_epicLink = customFieldManager.getCustomFieldObject(10001)
def epic = issue.getCustomFieldValue(field_epicLink) as Issue
def field_team = customFieldManager.getCustomFieldObject(10300)
def field_productArea = customFieldManager.getCustomFieldObject(10502)
if (epic != null) {
if (field_team != null) {
def value_team = epic.getCustomFieldValue(field_team)
issue.setCustomFieldValue(field_team, value_team)
}
if (field_productArea != null) {
def value_productArea = epic.getCustomFieldValue(field_productArea)
issue.setCustomFieldValue(field_productArea, value_productArea)
}
issueManager.updateIssue(currentUser, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok i know how to do but i have a error while compiling :
2019-02-21 10:05:54,844 ERROR [workflow.ScriptWorkflowFunction]: ************************************************************************************* 2019-02-21 10:05:54,845 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: CFDP-5382, actionId: 1, file: <inline script> groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getCustomFieldValue() is applicable for argument types: (com.atlassian.jira.issue.fields.ImmutableCustomField) values: [Team] at Script573.run(Script573.groovy:17)
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.