Hello,
We have recently upgraded to JIRA v 8.11.0
Our aim is to create a new Workflow which will create a new JIRA and set the Values of some Custom Fields.
The Workflow does:
However, the existing Custom Fields are not getting updated
Can someone give me a hint why I am not able to set the values of Custom Fields of newly created Issues even if the custom script runs after the issue is created ?
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.util.IssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
import org.apache.log4j.Category
// ComponentManager has been deprecated since JIRA 7.11
// https://community.atlassian.com/t5/Answers-Developer-Questions/Groovy-Post-function-on-Create-transition-can-t-set-custom-field/qaq-p/474592
log = Category.getInstance(“com.onresolve.jira.groovy”)
log.setLevel(org.apache.log4j.Level.DEBUG)
log.debug “start debugging ASS-1482”
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
IssueChangeHolder changeHolder = new DefaultIssueChangeHolder()
Issue issue = issue
def allCustomfields = customFieldManager.getCustomFieldObjects(issue)
def count = 0
def i=0
for(i=0;i<allCustomfields.size();i++){
log.debug “–”+allCustomfields[i].getFieldName()+"–"
}
log.debug “finished display customfields”
def opsKycField = customFieldManager.getCustomFieldObjects(issue).find {it.name == ‘OPS-KYC analyst’}
opsKycField.updateValue(null, issue, new ModifiedValue("", “SB36AU”), changeHolder)
log.debug "PR ID now set to: " +issue.getCustomFieldValue(opsKycField)
Additionally, nothing appears in the log file.
Test of ASS-1482
2020-09-15 11:29:34,249+0200 http-nio-8080-exec-15 INFO SB36AU 689x72783x1 pvctuf /secure/admin/ViewLogging!markLogs.jspa [c.a.j.util.log.LogMarker]
Test of ASS-1482 end
Hi @[deleted]
opsKycField.updateValue(null, issue, new ModifiedValue("", “SB36AU”), changeHolder)
The "" should be the old value.
you could do this
opsKycField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(opsKycField), “SB36AU”), changeHolder)
Let me know if this works for you.
Hi @[deleted] ,
Before getting into the script, I am thinking if you may need to reorder the workflow post function.
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.