Add workflow group condition programmatically

Deleted user July 7, 2021

Hi, I am trying to add a condition group using an upgrade task, how can I prevent jira from duplicating the condition group if it already exists (ex: if the upgrade task I need to rerun for any error). I have tried setting id at each conditions, but this doesn't work.

```kotlin

 

workflowDraft
.descriptor
.getTypedGlobalActions()
.find { action -> action.name == closed }
?.let { action ->

if (null == action.restriction) {
action.restriction = RestrictionDescriptor()
}
if (null == action.restriction.conditionsDescriptor) {
action.restriction.conditionsDescriptor = DescriptorFactory.getFactory().createConditionsDescriptor()
}
val rootConditionsDescriptor = action.restriction.conditionsDescriptor
rootConditionsDescriptor.type = WorkflowEditorTransitionConditionUtil.OPERATOR_OR

val rootConditions = rootConditionsDescriptor.conditions

val conditionsDescriptor: ConditionsDescriptor = DescriptorFactory.getFactory().createConditionsDescriptor()
conditionsDescriptor.type = "AND"
val conditions = listOf(
firstCondition,
secondCondition,
thirdCondition
)
conditionsDescriptor.conditions = conditions

rootConditions.add(conditionsGroup)}




```

Thanks in advance

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events