Looking for advice on streamlining an automation.
I'd like to have a list of values (applications/components/common pain points). For each issue created, i'd like to check the Summary and Description against that list, and for each match (eg summary OR description contains WiFi and Printing, to then add a label for each match. So this example would add 2 labels - 'WiFi' and 'Printing'.
I'm trying to condense this from a whole bunch of If/Else blocks... would appreciate any thoughts
Hi @Daniel Helmstedt -- Welcome to the Atlassian Community!
One way to do this would be to create your list of check values in a created variable, separated by commas. And then use advanced branching to iterate over them. For example
Another way to do this is with a regular expression, copying the source field (e.g. Summary) to a created variable, and then replacing anything not in your search list of terms with an empty string. Then parse the results into a smart value list and add all of the labels at one time using an advanced JSON edit expression.
Kind regards,
Bill
Thanks Bill! That's a much simpler flow than I was working on!
How would you go about checking the smart value against both Summary and Description - can that be done in one step?
Cheers!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Daniel.
If you mean the second thing I suggested, I meant removing the non-matching expressions (i.e. to your tests) with a RegEx and then using the remainder to create the list for the labels. This is certainly going to take a bit of experimentation to get correct; the specifics of your search strings may not make this approach viable.
The first approach I noted should be easy to try and get working...giving you time to experiment with the second approach. That would only require use of advanced compare conditions with "contains" or use of the text searching functions.
Regarding your ask about checking Summary and Description in one step, you could concatenate them first, and then test for the string match.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @[deleted]
I checked the link for text searching functions, as I wanted to do something similar, but I couldn't find anything for 'contains' other than contains all letter or all numbers, not matching keywords.
How does the syntax to match keywords work?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Matthew. Please try using match() with a regular expression, and then check that the result is not empty to then add the relevant labels.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy
I should probably have created a new ticket but this is exactly what I was searching for. I am trying to do the same thing but I just started yesterday.
would it be possible to further explain this:
How do I create a list, I’ve read through the smart values list but I am unsure of how to create a list
And once I do the check if the value is found, how do I input that as a label. I can’t see any way to pass the information from the list into the labels based on the results. If I could find out in general how this is done it would be great, because being able to pass the information from the branch to the action would be great
your help would be highly appreciated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ryan Van Zyl -- Welcome to the Atlassian Community!
First thing: lists
To make a list, you supply the values with some delimiter, such as comma. That will still be a text string. Then when you need it as an actual list, you can use the split() function for use as needed. For example...
Next thing: adding your found value as a label
This is the easy part, using Edit Issue, select Labels, the ... option to Add/Remove labels, and then just enter your smart value of {{myLabel}} from the branch. The "trick" is to type in your smart value in the field and it will appear below the field; when it does, select it to use it.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so much, I understand now how I am supposed to use smart values. I work for a big company (this is not my company email) and they want me to automate a lot so this really has saved me a lot of time.
Thank you so much again!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bill Sheboy @Ryan Van Zyl Can you elaborate on the first method explained (see below). I'm still not getting how to realise this.
"That would only require use of advanced compare conditions with "contains" or use of the text searching functions.
Regarding your ask about checking Summary and Description in one step, you could concatenate them first, and then test for the string match."
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The idea would be to use functions, such as match(), to extract the text you want to search, and use the value to check in the second compare value.
Another approach, suggested earlier, is to build a list of value to check in a created variable, and then iterate over them with and advanced branch to check them one by one.
If you already have a rule which is not working as you expect, I suggest creating a new question, adding a link to this post, and including images of your complete rule and audit log details. That will help more members of the community to see it and offer suggestions. Otherwise only the people currently following this post will see your question.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is really helpful in solving something I am trying to implement.
I am hitting a really odd issue though.
In my scenario, I have a custom field that looks like item1, item2, item3
I created a variable (VAR1) that populates with {{issue.customfield_11111}}
Then created the For each Smart value branch using {{VAR1.split(", ")}} as smart value VAR2. Yes this has an extra space since the original data had one and it failed previously.
Then I populate the label field with new (VAR2) variable
Rule runs successfully, but label only adds item2 as a label.
If I remove the refetch, the same occurs. I probably have missed something really stupid but not sure what
Edit: Removed the trailing space and now it only shows item3. Might be onto something
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Since I originally responded to this question, I learned more about this use case and the parallel processing of branches on more-than-one-thing (i.e., issue, value, etc.) Because of this one issue edit could "walk over" prior results. Although there could be another cause for your rule.
Without seeing the specifics of your rule, I suggest a better way to do this is to gather all possible label additions and build a JSON expression, and then perform one single issue edit using the advanced edit to add the labels.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy
Yes that is exactly what I was seeing. I will have go at trying the JSON expressions.
Not used that before so a bit unsure on how I can feed it a list of labels that is not pre-defined. Assume variables would work but would still need to then split it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is the documentation on adding labels with JSON, and here is an example of how to do this with created variables...
Let's say you want to set the hard-coded value in a variable and then add the label with JSON.
{
"update": {
"labels": [
{{varAddLabels}}
]
}
}
The created variable is building a string to use in the JSON.
Now if you wanted to add multiple new labels, based on your custom field, you change the variable to iterate from your custom field instead. This assumes your custom field is a multiple-select option list, so please adjust accordingly.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Had to step away form this a bit, but will try this and pick it up again when I can.
Thanks for the help! will reply once tried to confirm
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy
Managed to have another look at this. your comment states that the custom field is a multi-select list, which is not the case for me. I had not spotted that so I assume that is why I get JSON errors.
my custom field is a text field that literally would have Value1, value2, value3 as entries for example.
Using your suggestion I either keep getting invalid JSON or when I try to use a split function I get the "cannot contain space".
I tried using ".labels.asJsonStringArray" but that then failed with: (Specify the value for labels in an array of strings (labels)), which I assume suggests my variable is then not right.
I got the feeling I am close but just got that little gap in my kmowledge on how to manipulate the data.
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 images of your complete current rule, including details of any created variable actions or edits with JSON, and the details of the audit log showing the rule execution? That may help provide context for what you are seeing. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy
this is the current iteration
The steps are:
create variable:
for loop:
edit issue:
with the audit saying:
I am probably being really dumb to be honest
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No worries; writing automation rules is a lot about learning and experimentation, and we are all doing both of those things :^)
For your scenario, I would recommend using one edit to add the labels, rather than use branching, as I described earlier in this thread.
The difference is that rather than starting with a multi-select option field, you would feed this from a split of your text custom field, like this for the varAddLabels part:
{{#issue.customfield_11401.split(",")}}{ "add": "{{value}}" } {{^last}}, {{/}}{{/}}
The split turns for text field into a list, which then can be iterated over to build JSON to add labels.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi @Bill Sheboy
I had some level of success and failure with this.
If I set my rule to create a single variable using your split then have an edit issue field with the following JSON:
{
"update": {
"labels": [
{{LabelTest}}
]
}
}
The rule succeeds, but no labels get added.
Then I reasoned to change it to :
{
"update": {
"labels": [
{"add": "{{LabelTest}}"}
]
}
}
Which resulted in (The label '{ "add": "" } , { "add": "" } ' can't contain spaces. (labels)) again.
I then reasoned that I would try:
{
"update": {
"labels": [
{"add": [{{LabelTest}}]}
]
}
}
but that gave this error: (Operation value must be a string (labels))
I got a feeling it is close, but it just needs that last hurdle. I tried to add a space to the split function to get split(", ") but that still resulted in space error
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Let's check some things to see where the problem may be...
First thing, with this technique, you would have a single issue edit using JSON and no branch in the rule. Is that what you have currently? If not, please post image of your latest rule.
Next, please try writing just the created variable {{LabelTest}} to the audit log using the Log action. That will help confirm if the custom field is being converted properly into well-formed JSON.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy
Can confirm that all branching has been removed.
The log action was helpful. the output is:
log:
{ "add": "" } , { "add": "" }
based on the variable created with:
{{#issue.customfield_11401.split(", ")}}{ "add": "{{value}}" } {{^last}}, {{/}}{{/}}
so it would appear it is not happy with this variable.
I did add extra logging to see if the customfield did have a value which it does report:
log:
test1, test3
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks, and that helps a lot to explain this.
Your custom field is text, and you are splitting the value with a comma-and-space. That results in a list...and...the resulting items have no name, such as {{value}}
When iterating a list you can access the current item with {{.}} so please try this for your created variable:
{{#issue.customfield_11401.split(", ")}}{ "add": "{{.}}" } {{^last}}, {{/}}{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bill Sheboy that was the ticket! I tried list creation before but clearly did not do that correct.
Thank you so much for the help! this has been really valuable to me to learn
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Awesome! I am glad to learn that helped.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy
Would you please share the print of Automation that works?
I would like to copy selected values of combo box to Label field, since Combo cannot show in List view.
Many thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First thing, I recommend creating a new question and linking back to this one rather than adding more questions to it. Otherwise only the people following the older posts will see it to provide ideas. Thanks!
Next, if you review this thread's content, and how to use an advanced branch to iterate values, I believe you will have everything you need to create a rule to do what you ask.
Finally, using automation rules requires learning and experimentation. If you have started a rule and have run into challenges, please post images of your rule and the audit log in a new question, describe the problem you are trying to solve, and explain what is not working as expected.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bill
Will certainly post this in a new tread and explain the solution.
In the meantime, thanks for the inspiration for creating this workaround to update labels based on checkbox.
As I said, currently you cannot create filter on Jira Board or list based on checkbox, but you can update Labels on each checkbox change.
Cheers
On your_checkbox change
Variable = DisciplineLabel
{{#issue.your_checkbox}}"{{value}}"{{^last}},{{/}}{{/}}
Edit issue
{
"fields": {
"labels": [
{{DisciplineLabel}}
]
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Welcome to the Community!!
If you have a predefined list of labels that's best, otherwise, it's not recommended.
Have the list of labels predefined, and going forward for once you need to create the label and add it in automation.
The Automation would go like this
Trigger - Issue Created
Condition - JQL Condition to check whether labels you manually added once is present in Summary/Description
Action - Add the label
Thanks,
Pramodh
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.