Forums

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

Automation smart value. Converting list to numeric

Vadym Hrigorash December 21, 2023

Hi All.
I have two projects. The first one is Product Discovery which has a field as a list with weights (every option contains some value). Second one is Software Project. I created automation rule with smart values to copy some field from PD project to Software. It works if PD field is numeric but does not work with field which is list of options with values. On the Product Discovery itself I can calculate this field and copy it to another field.
Any advice, please, on how to convert this field to a number? This field can contain more than one option. They all are summarized and copied to another field (on the PD project).
Help, please   

4 answers

1 vote
James Smith February 6, 2024

@Bill Sheboy OK, I'm an idiot and completely missed out one step, the NULL variable. Sorry to waste your time. Thanks for all this amazing work!

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.
February 6, 2024

Hi @James Smith 

Did you mean to post your response in this thread or another one?  Thanks!

Kind regards,
Bill

0 votes
Vadym Hrigorash December 21, 2023

see below

0 votes
Vadym Hrigorash December 21, 2023



0 votes
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.
December 21, 2023

Hi @Vadym Hrigorash 

For a question like this, please post an image of your complete automation rule, images of any relevant actions / conditions / branches, an image of the audit log details showing the rule execution, and explain what is not working as expected.  Those will provide context for the community to offer ideas.  Thanks!

Until we see those...

When the rule gets those values from the multiple select, custom field, they are text.  To convert them to numeric values use the asNumber function.

For example, to get the value for one selection use:

{{issue.myCustomField.value.asNumber}}

You note the field is multiple selection, and so the specifics of how you are using the values will determine next steps.  Showing your rule and explaining further will help.

Kind regards,
Bill

Vadym Hrigorash December 21, 2023

Hi @Bill Sheboy

Thanks.
I changed Smart value to {{issue.myCustomField.value.asNumber}} and now it does not fail. But, it returns Zero despite the weight of the chosen option is 47.


The first image shows type of field and weights of their options. It is a Product Discovery project, by the way. Rule should calculate those value and store to Software Project field.

Thanks, in advance 

key_customer.pngSmart0.pngscreenshot_738.pngresult.png

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.
December 21, 2023

Ah, this is a JPD project and you are trying to access the "weight" value which (I believe) is dynamically calculated across selected values for a set.  Is that correct?

Vadym Hrigorash December 21, 2023

I think it's not dynamically calculated. it's set constantly but this is a list of options with weights.
The first goal was to get dynamically calculated value as it works on JPD but I couldn't do it. So I took this formula and focused on repeating this calculation from JPD fields and store to Software Project. I will be able to do it if I can convert field options (with weight) to number. So, this is the my task and this was a question
  

Vadym Hrigorash December 21, 2023

Shortly, I need a Smart value, like this {{issue.myCustomField.value.asNumber}} which returns 47, if 1st option is chosen (see first image).  And it will return 83 (47 + 36) if the 1st and 2nd options is chosen

Vadym Hrigorash December 21, 2023

I already checked:
{{destinationIssue.Key Customers.value.getValue().asNumber}}

{{destinationIssue.Key Customers.value.getValue}}

{{destinationIssue.Key Customers.value.getValue()}}

It didn't work. returns 1 as I make + 1. So, I suppose it is 0

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.
December 21, 2023

Using the how-to article linked below to find which smart values are supported by rules, I created a JPD multiple-select field with weighting: the weight values were not available to the rule.  Only the selected values were available.

https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

 

I recall helping someone with a similar JPD question a while ago, and the work-arounds were to either use a Lookup Table to get the weights or to use repeated text replacements (i.e., text value for the number value.)  The problem is both the field and rule need to be kept in sync.

An example of the text replacement would be this:

Assume a field with values of "Red", "Green", and "Blue", with weights of 1, 5, 10, respectively.  The total of selected weights would be this, using math operations:

{{#=}}0{{issue.myCustomField.value.join(" + ").value.replace("Red","1").replace("Green","5").replace("Blue","10")}}{{/}}

How this works:

  • get all of the selected values
  • join them together in a text string, separated by a plus sign
  • replacing each individual selection value with its weight
  • wrapping the entire expression as a math operation, with a default value of 0 at the front

 

Like Kevin Paulovkin likes this
Vadym Hrigorash February 9, 2024

Hello @Bill Sheboy sorry for not answering a long time. I was stuck with some weird issues and then didn't have time.  
At last, I did it the way you suggested. I works, it really works. thank you. Kudos to you :)

 

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.
February 9, 2024

Hi @Vadym Hrigorash  -- Thanks for the follow-up and confirming this approach helped. 

Please consider marking this solution as "answered"; that will help others with a similar need find answers more quickly.

Suggest an answer

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

Atlassian Community Events