Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Add workflow group condition programmatically

Miguel I'm New Here Jul 07, 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

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you