Hello everyone,
I ve got stuck with an Automation rule:
1. There is a manual trigger in an Epic which enables creation of multiple tasks.
2. Every single task should have the same components as the parent ID/Epic--> Copy from parent ID function provided by Jira.
3. But some tasks should have additional components.--> added a JSON in advanced options.
4.Result: the Parent ID component is displayed in the child task but not the additional component.
Could you pls help me with that.
Attached you ll find the way I tried to solve the issue.
Thank you all in advance ;)!
In a single Create Work Item action, one cannot select both a specific field from the dropdown list and update it with JSON. Usually, this leads to strange rule errors, although it could also create an unpredictable update.
The solution for your scenario is to first combine the Epic's values with the additional ones in a Created Variable, and then use that variable to dynamically build the JSON. This approach allows handling edge cases, such as when the parent Epic has no values or duplicates the additional one. (The duplicates may be removed using the list distinct function.)
Please let me know if you need help writing those rule actions.
Kind regards,
Bill
Hey Bill,
that sounds like a solution to my problem :). Could you pls lead me through every single step?
I have no experience either with Created Variable or with list distinct function. How it would look like?
Best regards,
Antonina
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First thing: in my experience, successfully using rules requires learning and experimentation.
I recommend pausing to understand the features needed from the documentation and trying simple test expressions, perhaps just writing results to the audit log, to learn what works. This is better than only implementing what you find in the community or read from bot-created suggestions...and will allow you to better write and maintain rules in the future.
With that in mind, please pause to read this information, and any links I add below:
Next, let's assume the trigger issue is the Epic with the Components you want to add to the new work item, plus more values. And so we create a variable with all those values:
{{triggerIssue.components.name.join(",")}},NewValueA,NewValueB
That uses inline-iteration to get the Epic's Component names, joining them with commas, and then adding any new values at the end with comma separators.
But that could include duplicates if a value, such as NewValueA, already exists in the Epic. And so we need to clean that up in the variable:
{{varComponentsToAdd.split(",").match("(.++)").distinct}}
Created variables are plain text, and so we split() the variable back into a list, using the match() function to eliminate any empty values using a regular expression, and finally using distinct to remove duplicates. We use this expression to create the dynamic JSON:
{
"fields": {
"components" : [
{{#varComponentsToAdd.split(",").match("(.++)").distinct}}
{
"name": "{{.}}"
} {{^last}}, {{/}}
{{/}}
]
}
}
This iterates over the list to add each component for a single update, with commas after each item except the last one.
Please read the steps to ensure you understand them before trying in a rule. And remember to test with example work items to reduce impacts to your teammates.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Antonina Yudina ,
I just tested this on a local test system and I would say your syntax is fine.
In my example I've used the following code to add a Component to the ones that were already on a work item:
{
"update": {
"components": [{
"add": {"name": "Test3"}
}]
}
}
This leaves me with the suspicion that this could be a conflict in the action itself. I assume both of your screenshots are in the exact same Action in the Automation?
In this case, it could be that the advanced part of the action is run first (adding the component "Organisatorisch" and then the copy process is started afterwards which could replace the previous component.
The easiest way to test and fix this would be to have a second action element to apply the additional component.
I've also tested a bit with using one advanced element to add both the parent components and the additional component, but getting the JSON right with an iteration of the parent's components is quite challenging.
I hope that helps!
Greetings
Philipp
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Philipp,
thank you a lot for your prompt response. I thought about using labels instead of components. But that would be an emergency solution :).
Cheers,
Antonina
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.