Forums

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

Chaining Smart values expression

Gautam Poddar August 18, 2021

I've Field 'A' of single select drop down with values -

One

Two

Three

Four

I'm trying to write automation logic which will update another number field 'B' to a number corresponding to value of field 'A'. However seems I'm missing something to make it work correctly, none of the following expression syntax working for me -

{{issue.A.replace("Four",4).replace("Three",3).replace("Two",2).replace("One",1).asNumber}}

{{issue.A.replace("Four","4").replace("Three","3").replace("Two","2").replace("One","1").asNumber}}

 

Appreciate any help with this.

1 answer

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.
August 18, 2021

Hi @Gautam Poddar -- Welcome to the Atlassian Community!

When you note "...none of the following expression syntax working for me...", what are you observing happening?  What do you see in the audit log?

Have you tried to split this expression up incrementally and write to the audit log to see what is happening?  For example:

  • {{issue.A}}
  • {{issue.A.replace("Four",4)}}
  • {{issue.A.replace("Four",4).replace("Three",3)}}
  • ...

 

Best regards,
Bill

Gautam Poddar August 18, 2021

Hi @Bill Sheboy ,

Thanks for responding.

Yes, I looked into the audit log but it just shows blank/null value at the placeholder.

I tried splitting up the expression too as you've indicated for troubleshooting but not much luck with that either.

{{issue.A}} returns the selected value e.g. Four however {{issue.A.replace("Four",4)}} returns nothing while the audit log shows success.

 

Thanks,

Gautam

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.
August 18, 2021

Thanks, and that may mean some typing-issues are happening.

Please try: {{issue.A.value.replace("Four","4")}}

Like Gautam Poddar likes this
Gautam Poddar August 18, 2021

Thanks @Bill Sheboy

That definitely did the trick! now it's working fine. Also I noticed {{issue.A.value.replace("Four","4")}} works but {{issue.A.value.replace("Four",4)}} doesn't.

Just to summarize for benefit of others in future, the correct expression here would be {{issue.A.value.replace("Four","4").replace("Three","3").replace("Two","2").replace("One","1")}}

Like Bill Sheboy likes this
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.
August 18, 2021

Yup, that makes sense for the same reason: the replace function is taking two string parameters.

I am glad to hear that is working.  Please consider marking this question as "answered" to help others in the community searching for solutions find them faster.  Thanks!

Like Gautam Poddar likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events