Hello,
I have a problem with my Behaviour initialiser for the Constrained create issue Script Fragment. Even if I wrote all my code using if (getBehaviourContextId() == "link-create-LM") { , there is no change on my creating issue screen when i get to it using the button.
I read online that there were problems concerning Constrained create issue with behaviours, but I have Jira version 8.7.1 and ScriptRunner Version 6.2.1 so it should be okay. I also tried to place my button at different spots (operations-top-level and jira.issue.tools) and both don't work.
The weirdest thing is that it was working at the beginning, but I changed a little bit my script and nothing works anymore. I tried to write the original screen back and nothing works.
Do anyone know what could be the problem ?
Here's my behaviour initialiser code
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
def issueManager = ComponentAccessor.getIssueManager()
if (getBehaviourContextId() == "link-create-LM") {
getFieldById("project-field").setReadOnly(true)
getFieldById("issuetype-field").setReadOnly(true)
def contextIssue = issueManager.getIssueObject(getContextIssueId())
def defaultValue = """PRJ créé à partir de : ${contextIssue.key}
En tant que
Je veux
Afin de """.replaceAll(/ /, '')
getFieldById("description").setFormValue(defaultValue)// Ajouter à la description et aux linked issues le lien vers l'Opportunité
getFieldById("issuelinks-linktype").setFormValue("relates to").setReadOnly(true)
getFieldById("issuelinks-issues").setFormValue(contextIssue.key).setReadOnly(true)
getFieldById("customfield_13800").setFormValue(contextIssue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_13800"))).setReadOnly(true)
def typeDemande = getFieldById("customfield_13800").getFormValue()
if (typeDemande == "Demande client") {
getFieldById("customfield_14012").setFormValue(contextIssue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_14012")))
getFieldById("customfield_10606").setFormValue(contextIssue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_10606")))
}
}
I have tried setting this up in my instance and except for the customfields, which I don't have, it works perfectly.
Have you checked the logs for errors?
@Mathis Hellensberg Thanks for your answer. Because of what you said, I tried the script without the customfields and it is working. But when I add the customfields in the code nothing work. The project and Issue type fields aren't even Read only anymore. Do you have any idea what could be the problem?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hmm maybe you got an ID wrong or one of the fields you are manipulating is of an unsupported type. Try adding one at a time to figure which one is failing :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found the problem, it is for all select list custom field.
When i use getCustomFieldValue it returns a String, but setFormValue uses the option id of the custom field which is a long so it's not possible to set the form value that way. If anyone is interested by that issue, I set the form Value by using that script
def typeDemandeField = customFieldManager.getCustomFieldObject("customfield_13800")
def contextTypeDemande = contextIssue.getCustomFieldValue(typeDemandeField) as String
def config1 = typeDemandeField.getRelevantConfig(contextIssue)
def options1 = optionsManager.getOptions(config1)
def optionToSelect1 = options1.find { it.value == contextTypeDemande }
getFieldById("customfield_13800").setFormValue(optionToSelect1.optionId)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I’m glad you found a fix! :)
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.