Hi there! For the sake of this question we have three custom fields in play:
CustomField1 - a single select Radio Buttons field
CustomField2 - a Checkbox field
CustomField3 - another single select Radio Buttons field
We need to power a couple automations based on combinations of these fields, but CustomField2 has 12 options in it so the possible permutations would be a lot to hard code. What we want to do is iterate through the list of CustomField2 selections on an issue, and create labels combining the values of all 3 fields together.
Example:
Customer selects CustomField1 "Value A"
Customer selects CustomField2 "Value A", "Value D", "Value F", "Value M"
Customer selects CustomField3 "Value C"
Ideally this creates 4 labels:
CustomField1.A-CustomField2.A-CustomField3.C
CustomField1.A-CustomField2.D-CustomField3.C
CustomField1.A-CustomField2.F-CustomField3.C
CustomField1.A-CustomField2.M-CustomField3.C
in the issue
Is this possible?
I suggest not using branching to solve this. Branches on more-than-one-thing (e.g. JQL, advanced branches, etc.) process asynchronously and in parallel. If you are repeatedly trying to update the same issue you could run into collision and timing challenges.
Another way to solve this, and make one single issue edit, is to use an iterator over your multi-select field to build all of the labels in one JSON expression, and then use advanced edit to save them.
For example...
{{#issue.customField2}}{ "add": "{{issue.customField1.value}}-{{value}}-{{issue.customField3.value}}" } {{^last}}, {{/}}{{/}}
This works by iterating over the values of your customField2, and adding the other field values around them, to build up a JSON expression.
{
"update": {
"labels": [
{{varAddLabels}}
]
}
}
Three more things...
I recommend adding a condition after your trigger to check if your fields have any values selected before proceeding to adding/changing labels.
What do you want to do if the custom field values change? Rather than performing updates, you may need to first remove all existing labels and always write them anew. If that cannot be done for some reason, I suspect this approach may not be viable for you.
And, automation is often about experimentation and learning. It can help to look at the examples in the automation library to combine ideas from other rules to solve your needs.
Kind regards,
Bill
Great idea with using the iterative on the second custom field value! I’m still trying to get used to using this and seeing more examples like this really me dig deeper into Automation capabilities. Bravo!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This feel so close! It's definitely iterating an printing multiple labels but for whatever reason the {{varAddLabels}} variable is only getting populated with the value of the second field (eg the one that's just {{value}}). Am I missing something in the syntax here? Everything else is in the format of issue.customfield
The individual parts of the (eg customfields 1 and 3) have a valid value when checked in the audit log, just for whatever reason they're not showing up creating the AddLabels variable
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Would you please post an image of your Create Variable action for varAddLabels? This could be an iterator thing that needs some adjustments.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Added a codeblock since its a bit wide to screenshot
Custom Field 1 is a date
Custom Field 2 is the multi-select checkbox (parses correctly)
Custom Field 3 is a number
Rest are standard fields.
{{#issue.CustomField2}}{ "add": "{{issue.CustomField1.format("yy")}}{{issue.project.key}}{{CustomField2}}{{issue.CustomField3.round}}{{issue.summary.charAt(0).capitalize()}}" } {{^last}}, {{/}} {{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Okay, my mistake...I forgot something I learned a while ago: once inside of an iterator, you cannot access things (e.g., smart values) from a higher scope.
And so once inside the iterator for your custom field, the issue fields are no longer visible. The work-around is to build this expression in steps, by first iterating and then adding your other content.
{{#issue.CustomField2}}{ "add": "DATEFIELD PROJECTKEY {{value}}NUMBERFIELD SUMMARYSTART " } {{^last}}, {{/}} {{/}}
{{varAddLabels.replace("DATEFIELD ", issue.CustomField1.format("yy")).replace("PROJECTKEY ", issue.project.key).replace("SUMMARYSTART ", issue.summary.charAt(0).capitalize()).replace("NUMBERFIELD ", issue.CustomField3.round.format("#"))}}
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.
What is the end goal of getting these concatenated labels created? And why do you need each permutation as a separate label? I'm just trying to understand the logic.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We functionally need to create a "UPC" or (however you want to think of a unique identifier) that contain information derived from several shared custom fields. The checkbox field contains the version that can differ between related products. The idea is to store these UPCs as labels because there may not be a strict 1:1 relationship between a product and a "run" of that product
Think of it like:
Car Model A, and having to create UPCS for Car Model A (Blue), Car Model A (Red), and Car Model A (Yellow) so we can create Issues for the production runs of the red, yellow, and blue cars.
Automation current looks something like this:
"Order Versions" field is the colors of car basically
The {{NewOrder}} variable is the UPC based on the static fields, and the color
it quite nearly works, but the automation doesn't seem to be returning to the "top" of the loop and only creating the UPC for the "Blue" car if all 3 colors are selected.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.