Forums

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

Problems with lookups and multiplying values

Izzy Clatworthy June 19, 2023

Morning,

I'm trying to create a scoring system for our issues. This is done by the person filling out the form entering a priority and severity value from lowest to highest (with low, medium and high in the middle).

I have then got a look up table relating these to values 1-5

I am then creating smart variables to lookup the value in the table that is provided in the issue.

{{#=}}{{Lookup.get(issue.Priority.value)}}{{/}}

{{#=}}{{Lookup.get(issue.Severity.value)}}{{/}}

I then use these issues in an if else block,

If {{severityValue}}*{{priorityValue}} is less than 5 show low

If {{severityValue}}*{{priorityValue}} is greater than 12 or either value equals 5 show high

Else show medium.

I can not get this to work however. I think it is the multiplication part of this that has become my downfall, I've tried many many variants of it and can't seem to get it to work. It just automatically goes to medium every time unless either input is highest so equal to 5. This returns a high

Thank you in advance

2 answers

2 accepted

0 votes
Answer accepted
Izzy Clatworthy June 26, 2023

Hello, following the suggestion to log the variables I've managed to work out it was the priority field giving  us an Issue due to us using the Jira field Priority rather than a custom field.

We've managed to solve it and I've had a mini celebration.

Thanks for all the help.

Jira problem example 8.png

John Funk
Community Champion
June 26, 2023

Great! Glad you got it working. 

0 votes
Answer accepted
John Funk
Community Champion
June 19, 2023

Hi Izzy,

Can you share the actual rule that you have now, showing the details of the field for the calculation? 

Also, try adding some log actions to that will show you the value after to select it to be sure it is returning the values you expect it to. 

Izzy Clatworthy June 19, 2023

Hi @John Funk 

I'm currently using {{severityValue}} * {{priorityValue}} in the first value field on an if else blockJira problem example 1.png

Thank you I'll try adding some log actions

Like John Funk likes this
John Funk
Community Champion
June 19, 2023

You are not going to be able to put two values in the First Value field. You could create a variable using that calculation first, then use the variable name in the First Value field.

Izzy Clatworthy June 19, 2023

Ok thank you, I have created a new variable to put the function in, however I can still not get it to work. If I use 

{{severityValue}} * {{priorityValue}}

It just returns an error saying it is missing parameters

If I use 

{{#=}}{{severityValue.multiply(priorityValue)}}{{/}}

It just returns the else option of the if else block when it shouldn't.

@John Funk 

John Funk
Community Champion
June 19, 2023

Can you share the full rule? 

Izzy Clatworthy June 19, 2023

Jira problem example 2.pngJira problem example 3.pngJira problem example 4.png@John Funk Thank you for all your help so far

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.
June 19, 2023

 

Hi @Izzy Clatworthy 

Yes, and...to what John suggests...

In your rule, you are initially using an if-condition only rather than if-else clauses.  That would cause processing to stop after the first condition.  Please try changing your rule to something like this:

  • if some condition
    • action
  • else-if another condition
    • action
  • else 
    • action

And also I wonder if your severityValue and priorityValue variables are correct, as you do not show the specifics of them in the rule images.  Perhaps write those to the audit log after they are set to confirm the values.

Finally, rules can get a bit long in the browser, so consider using a screen capture or browser addon to create a scrolling page image of the entire rule.  That will help for posting one rather than multiple images to show longer rules.  Thanks!

Kind regards,
Bill

Izzy Clatworthy June 19, 2023

Thanks @Bill Sheboy I've changed it to an if, else if and if and It's working slightly better. It is still stumbling on the formulas though. It now is returning low (The first option in the if) rather than anything else. I'll attach screen captures of all my variables. Thank you for the tip :)Jira problem example 5.pngJira problem example 6#.pngJira problem example 7.pngJira problem example 8.png

As previously stated, just using a "*" is tripping up the automation entirely.

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.
June 19, 2023

Thanks for that information.  When you write the variables to the audit log, do you observe the values you expect?

Created variables are text, and need to be converted with asNumber before math operations, so that may also be a problem with the rule.

 

Regarding math operations, there are two formats which work: in-line and a math operation.  For example:

{{severityValue.asNumber.multiply(priorityValue.asNumber)}}

or

{{#=}}{{severityValue.asNumber}}*{{priorityValue.asNumber}}{{/}}

 

And also...Using lookup tables does not require using the math operation: you use it directly like lookup issues:

  • action: create variable
    • name: severityValue
    • smart value: {{Lookup.get(issue.Severity.value)}}

 

One more: I recommend naming your lookups, and variables, with meaningful names to reduce confusion (for people and the rules engine).  I would also avoid using reserved word names.  In general, I prefix all of my variables and lookups with var, such as varSeverity and varScoreToNumber.

Like John Funk likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events