You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hello,
I'm looking to use jira automation rules in an advanced way using variables in smart value functions.
I saw that a ticket covered this topic some time ago but even though it is marked as resolved I am having trouble applying the syntax.
Here is the ticket : https://codebarrel.atlassian.net/browse/AUT-168
I want to do the same, e.g. :
{{issue.summary.replace("blah", "{{issue.fields.reporter.displayName}}")}}
Is there a way to use variables in smart value functions?
Yes, that works. If you remove the quotation marks and extra curly braces that would work. For example:
{{issue.summary.replace("blah", issue.reporter.displayName)}}
Best regards,
Bill
Hi @Bill Sheboy
Thanks a lot for your answer.
I tried to combine your solution with a variable added by "Create variable"
But I failed to use this variable in the replace method. This didn't return anything using the variable whereas it did return something when I directly used values like fieldChange.fromString and fieldChange.toString (the trigger of my action is a change of a field)
Instead of using a custom variable, I used a way to concat "[" and "]" with another topic (https://community.atlassian.com/t5/Jira-questions/Smart-value-with-concatenate-string-in-string-replace-replaceAll/qaq-p/1363587)
Here is my final code that do what I want to do :
{
"fields": {
"summary": "{{issue.summary.replace(fieldChange.fromString.left(0).concat("[").concat(fieldChange.fromString).concat("]"), fieldChange.toString.left(0).concat("[").concat(fieldChange.toString).concat("]"))}}"
}
}
There is probably some way to make it prettier but I stop my search here!
Thanks again !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, and I am glad you got that to work!
Regarding Create Variables, they definitely need some investigation and improvements to be a more useful tool for automation rules. Currently, I have only found them useful to build JSON strings for complex edits and to remove things from lists (e.g. Components).
Best regards,
Bill
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.
I have discovered a similar issue, where I am unable to use earlier created variables as function arguments in smart values, and the workaround is to use issue entity properties instead:
https://community.atlassian.com/t5/Jira-Service-Management/Re-Pass-in-function-parameters-by-reference-in-smart-val/qaq-p/1806987/comment-id/87452#M87452
For some issue, which has at least 6 comments, automation goes as follows...
Create smart variable:
Variable name: commentNumber
Variable value: 5
Set entity property for issue:
property name: prop_commentNumber
property value (JSON):
{"val": {{commentNumber}} }
Log action:
{{issue.comments.get(issue.properties.prop_commentNumber.val)}}
Is it the best approach at this moment, and there is a bug in accessing list elements via smart variable values?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Boris,
Did you figure this out?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
I am trying to get something similar too. Anyone got this working. I am filtering a list of email address (about 3 or 4) and want to filter out only example.com emails and the string example.com is in a variable domain - I would like to do something like:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I just retested this to answer another question: the match() function still cannot accept variables for a regular expression for Jira Cloud.
And...if you are using Server/Data Center I also doubt this would work as those versions do not have Create Variable with which to make the regular expression dynamic.
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.
Thanks for the response @Bill Sheboy - that is a pity. We are on Jira Cloud.
I wonder if anyone else has got this working or found a workaround apart from hardcoding the domain (or anything else) instead of using the variable.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
After a bit more research, I found a work-around I created a year ago for this problem, bypassing the need to use the match() function:
CompanyName1|CL1,CompanyName2|CL2,CompanyName3|CL3,
{{issue.reporter.emailAddress.substringAfter("@").substringBefore(".")}}
{{varClientIdList.substringAfter(varReporterEmailDomain.concat("|")).substringBefore(",")}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We couldn't use variables inside .match(), then we just use .replace() before and after the use of .match() because replace accepts variables as input.
i.e.:
Using the field description = "a@a.com,b@b.com,2@a.com,c@c.com"
Automation:
Results:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I believe created variables can be used inside the match() function. The trick is to leave off the outer quotation marks and to let the function assume them around the variable representing the regular expression.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.