Hi everyone,
I use behaviours because I want to change the description of my issues in accordance of the Pre-Qualification (it's a custom field which is a Select List).
But i don't know why but my script don't work except when I comment on the part between number 1 and 2. I don't see errors and when I put it in the "Script Console" the part(between number 1 and 2) works.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.*
import com.atlassian.jira.issue.fields.*
//1
//Issue and CustomField Manager
IssueManager issueManager = ComponentAccessor.getIssueManager()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
//Issue's Id
long issueId = underlyingIssue.getId()
//the current issue
Issue issue = issueManager.getIssueObject(issueId)
//CustomField Name
CustomField customField = customFieldManager.getCustomFieldObjectByName("Pre-Qualification")
//Value of the CustomField of the current issue
Object customFieldValue = customField.getValue(issue)
//2
def desc = getFieldById("description")
def bugValue = """
*For a Bug
*Navigateur / Brower* : _Chrome v70, IE10 ..._
*Terminal / Device* : iPhone X iOS 12.0, Sony Xperia XZ1, Window XX, Mac, IPad, ..
*Environnement / Environment:* _QA , Prod, ..._
*Pré-requis / Pre-requisites* :
*Etapes / Steps* :
# _..._
# _..._
# _..._
*Résultat attendu / Expected result* : _Description_
*Résultat obtenu / Actual result* : _Description_
*Systématique / Systematic ?* _Y / N_
""".replaceAll(/ /, '')
if (!underlyingIssue?.created && !underlyingIssue?.description) {
if(customFieldValue.getValue() == "Bug"){
desc.setFormValue(bugValue)
}
}
to sum up, when i put this script without the part 1->2 in the behaviour edit its work but all the choice in the Pre-Qualification List have the same description which is "bugValue". And when i comment-out the part, nothing work and i don't know why.