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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
👋 Hi there Jira Community! A few months ago we shared with you plans around renaming epics in your company-managed projects. As part of these changes, we highlighted upcoming changes to epics on...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.