using Adaptavist Script Runner plugin > Behaviour
def desc = getFieldById ("description")
def defaultValue = """ *Some text in bold*
since we have a multiline string, we can put some more
but keep it short, this is a template...
What / Why / How ...""".replaceAll(/ . /, '')
if (! underlyingIssue.descrption) {
desc.setFormValue(defaultValue)
}
Affichage des articles dont le libellé est script runner. Afficher tous les articles
Affichage des articles dont le libellé est script runner. Afficher tous les articles
vendredi 10 janvier 2020
lundi 30 janvier 2017
JIRA Script Runner / split cascading field in two text fields
JIRA 7.1.7
Script Runner 4.3.16
Script Runner 4.3.16
import
com.atlassian.event.api.EventListener
import
com.atlassian.jira.component.ComponentAccessor
import
com.atlassian.jira.event.issue.AbstractIssueEventListener
import
com.atlassian.jira.event.issue.IssueEvent
import
com.atlassian.jira.event.type.EventDispatchOption
import
com.atlassian.jira.issue.IssueManager
import
com.atlassian.jira.issue.CustomFieldManager
import
com.atlassian.jira.issue.MutableIssue
import
com.atlassian.jira.issue.fields.CustomField
import
org.apache.log4j.Logger
def
cfNameCascading =
"Cascading Field Name"
;
def
cfNameFirst =
"Cascading Field Name : part 1"
;
def
cfNameSecond =
"Cascading Field Name : part 2"
;
IssueManager issueManager = ComponentAccessor.getIssueManager()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
/** Get the different CF objects**/
CustomField cfCascading = customFieldManager.getCustomFieldObjectByName(cfNameCascading)
CustomField cfFirst = customFieldManager.getCustomFieldObjectByName(cfNameFirst)
CustomField cfSecond = customFieldManager.getCustomFieldObjectByName(cfNameSecond)
/** Get Cascading Field values (map) **/
Map cfVal = issue.getCustomFieldValue(cfCascading)
as
Map
if
(cfVal) {
String valFirst = cfVal.
get
(
null
);
String valSecond = cfVal.
get
(
"1"
);
List allValues = cfVal.values()
as
List;
log.info(
"First - second: $valFirst - $valSecond"
);
log.info(
"All: $allValues"
);
/** Set each separate CF **/
issue.setCustomFieldValue(cfFirst, valFirst);
issue.setCustomFieldValue(cfSecond, valSecond);
/** update the issue **/
issueManager.updateIssue(event.getUser(), issue, EventDispatchOption.DO_NOT_DISPATCH, false);
}
else
{
log.info(
"Custom field not present on this issue"
)
}
Inscription à :
Articles (Atom)