Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Usage of variables in smart values

Peter van de Lageweg October 13, 2023

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:

  1. When: Some trigger
  2. Then: Create variable 
    1. Variable name --> variableX
    2. Smart value  --> {{issue.description.lastIndexOf("final")}}
  3. And: Edit issue fields
    1. Choose the description field
    2. with the value --> {{issue.description.abbreviate({{variableX}})}}

 

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?

 

 

2 answers

1 accepted

1 vote
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 13, 2023 edited

Hi @Peter van de Lageweg 

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

Peter van de Lageweg October 16, 2023

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

Like • Bill Sheboy likes this
0 votes
Tim C
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 13, 2023

Hi @Peter van de Lageweg 

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.

Peter van de Lageweg October 16, 2023

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?

Like • Patrick Binggeli likes this
Tim C
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 16, 2023

Hi @Peter van de Lageweg 

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"))}}

Screenshot 2023-10-16 124338.png

FYI. Here's the result (adding "..." as expected - 4 characters before the last "final").

Screenshot 2023-10-16 124513.png

I hope this helps?

Peter van de Lageweg October 16, 2023

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!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
atlassian, atlassian community, loom ai, atlassian loom ai, loom, atlassian ai, record recaps of meetings, meeting recaps, loom recaps, share meeting recaps,

Loom’s guide to great meetings 📹

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!
AUG Leaders

Atlassian Community Events