I have a table in story description like below. I want to search the description with specific field and get the value. I tried with Match function but not able to achieve it.
Expected:
1. When string matches "ABC" then I want output as 1,2,3
2. When string matches "DEF" then I want output as 2 AM
3. When string matches "GHI" then i want string as 3 AM
Can you help me with solution
|ABC|1,2,3| |DEF|2 AM| |GHI|3 AM|
Hi @rajvr -- Welcome to the Atlassian Community!
You appear to be asking a question about an automation rule. Is that correct?
If so, please note context is important for the community to help. Please post the following:
Until we see those...
Let's assume you only have a single table (with markup) in your Description field. If that was written to the rules audit log directly, it would look like this, assuming there is a header row:
||*my key*||*my value*|| |ABC|1,2,3| |DEF|2 AM| |GHI|3 AM|
Where the rows have a newline between each one. That information may be used with the split() function, creating a list of the rows, enabling the match() function to parse them one by one. For this scenario, the pipe | characters need to be escaped in the regular expression passed to the match().
For example, to get the "value" for the row with a "key" of ABC, that expression could be this:
{{issue.description.split("\n").match("\|ABC\|(.*)\|")}}
Please update the regular expression based on the actual column structure, especially when there are header rows / columns.
Kind regards,
Bill
Thank you @Bill Sheboy
one more help.
In the same example, When string matches to "ABC" then I want to add 1,2,3 in labels. How can we achieve it?
I have tried with for loop branch but it is not working.
||*my key*||*my value*|| |ABC|1,2,3| |DEF|2 AM| |GHI|3 AM|
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please show what you are using in the Edit Issue action to add the labels.
Are you trying to match multiple values with "ABC" or a single value? For a single value, the branch should not be needed: just use the ADDREMOVE labels option and enter the smart value expression.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In my smart value {{test}} I have 1,2,3. I want to add three labels one by one.
Currently it is trying to add 1,2,3 as a single label.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In that case, the found value must be split() on the commas to create a list for branching:
{{issue.description.split("\n").match("\|ABC\|(.*)\|").split(",")}}
Pausing a moment: what problem are you trying to solve? That is, why do this?
The scenario you describe is sounding more and more like a contrived example, almost as if it is a question from a test. Is that the case?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When ever there is a change in story description I want to find the string ABC from the story description and add the labels (1,2,3) to the story Labels field.
|ABC|1,2,3| |DEF|2 AM| |GHI|3 AM|
I tried adding split to my existing smart value but still i am not able to add label one by one. I am getting error like "The label '1, 2, 3' cant contain spaces".
I have below observations.
1. My final split is having space in between.
2. It looks like considering all 3 as a single lablel
{{issue.description.split("\n").match("\|ABC\|(.*)\|").split(",")}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you are adding the labels whenever the Description field changes, couldn't that cause prior values to remain in the Labels field?
Back to what you describe: updating the labels this way with an advanced branch may cause problems from multiple work item edits in a short timeframe. It is better to perform a single edit / update using a dynamic JSON expression with advanced edit.
First some assumptions:
If those assumptions are valid, you could use this dynamic JSON expression to add the labels:
{
"update": {
"labels": [
{{#issue.description.split("\n").match("\|ABC\|(.*)\|").first.split(",").trim()}}
{
"add": "{{.}}"
} {{^last}},{{/}}
{{/}}
]
}
}
How that works:
Please pause to fully understand that expression, reading the documentation references, before using it in your rule.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Bill Sheboy Thank you very much, it worked as expected. Yours assumptions are correct in my requirement.
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 it is working! Please consider marking this question as "answered" to help others with a similar need find solutions faster. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Today only! Share what you’re the most excited about for Team ‘25 or just dance out the beginning of a new quarter with us.
Comment the postOnline 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.