Just wondering, for automation is it possible to use variables as input in smart values?
For example: In the description field there is text that contains the word "final", and after that word all text should be deleted.
In automation I would create it like this:
Result is an error: Failed to get value for issue.description.abbreviate({{Signature: {{issue.description.abbreviate({{Signature}})}}
In the log I can see that in step 2 my variableX get's a numeric value, which I would expect. However this numeric value is not recognized in the smart value in step 3.
Is there something I do wrong, or is this not (yet) possible?
Sometimes yes and sometimes no...You essentially need to experiment with the functions to learn which ones can do this.
And even then, context is important. For example, if there is anything which collapses to null in the expression, the entire thing will either collapse to null or raise an error. Same thing in math or conditional expressions: test and experiment to learn what is possible.
And remember to check the types of parameters accepted to the function, and add conversions when needed. Such as passing text when a number is expected (like for abbreviate) will fail silently rather than working.
For your example scenario, using the function substringBeforeLast() would be better as you have a known text expression: "final". Please look here for more information: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#substringBeforeLast-String-separator-
When you need something a bit more dynamic, you need to get creative. For an example, take a look at this post for how to dynamically do something based upon the numeric value in a field: https://community.atlassian.com/t5/Automation-articles/Branching-over-smart-values-in-Jira-Automation/ba-p/1741935#M531
Kind regards,
Bill
Thank you for answer @Bill Sheboy
Unfortunately it seems that you have to experiment with this, since behaviour seems to be inconsistent.
Kind regards,
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Previously, I myself lost very many hours over this same issue with smart variables ....
Yes, you can include variables within the smart value - but strangely you don't have to include the double curly-brackets around the variable inside the smart value just the variable name.
Give the following a try ...
{{issue.description.abbreviate(variableX)}}
I hope this helps,
Tim C.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you @Tim C
I tried your syntax, but the result is that all text is deleted from the field. Perhaps it works better on other methods?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I just checked and this definitely works fine ... you don't need to create the "variable" so can find and edit within the same smart variable ...
{{issue.description.abbreviate(issue.description.lastIndexOf("final"))}}
FYI. Here's the result (adding "..." as expected - 4 characters before the last "final").
I hope this helps?
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 elaborate explanation @Tim C
However the example was hypothetical, I know I could have solved this example in a more simple way, my question was regarding using a variable inside of a smart value.
From the answer @Bill Sheboy provided, I now know it's not straight forward, and requires some experimenting.
Many thanks for your answers, it provides more clarity on the syntax!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Join us to learn how your team can stay fully engaged in meetings without worrying about writing everything down. Dive into Loom's newest feature, Loom AI for meetings, which automatically takes notes and tracks action items.
Register today!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.