Conditional Logic for Updating Custom Field Based on Another Field's Value
Asked by Gregory:

Hello everyone,

I'm trying to set up a JIRA automation rule to automatically update a custom field called V-Impact based on the value of another field, Time Saved. Here's the logic I'm aiming for:

* V-impact = 1 if Time Saved \<= 4
* V-impact = 2 if 4 \< Time Saved \<= 8
* V-impact = 3 if 8 \< Time Saved \<= 12
* V-impact = 5 if 12 \< Time Saved \<= 20
* V-impact = 8 if 20 \< Time Saved \<= 32
* V-impact = 13 if 32 \< Time Saved \<= 52
* V-impact = 21 if Time Saved \> 84

I've tried using smart values in the JIRA automation if statements, but it keeps filling the V-Impact field with an empty value no matter the value in Time Saved.

Here's the expression I tried:

{{#if(issue.Time Saved\|0 \<= 4)}} 1 {{/}}

{{#if(issue.Time Saved \> 4 and issue.Time Saved \<= 8)}} 2 {{/}}

{{#if(issue.Time Saved \> 8 and issue.Time Saved \<= 12)}} 3 {{/}} {

{#if(issue.Time Saved \> 12 and issue.Time Saved \<= 20)}} 5 {{/}}

{{#if(issue.Time Saved \> 20 and issue.Time Saved \<= 32)}} 8 {{/}}

{{#if(issue.Time Saved \> 32 and issue.Time Saved \<= 52)}} 13 {{/}}

{{#if(issue.Time Saved \> 84)}} 21 {{/}}

I would appreciate any guidance on how to correctly implement this logic in JIRA automation, or if there is a better approach to achieve this.

Thank you in advance for your help!

Gregory


Answers:
author: Manoj Gangwar
body: Hi [@Gregory](/t5/user/viewprofilepage/user-id/5207655) Welcome to the community!

Using the if/else structure is more efficient than stacking separate if blocks. You can achieve this with a single smart value expression using if/else like this

{{#if(issue.fields.Time Saved \<= 4)}}1

{{else if(issue.fields.Time Saved \> 4 and issue.fields.Time Saved \<= 8)}}2

{{else if(issue.fields.Time Saved \> 8 and issue.fields.Time Saved \<= 12)}}3

{{else if(issue.fields.Time Saved \> 12 and issue.fields.Time Saved \<= 20)}}5

{{else if(issue.fields.Time Saved \> 20 and issue.fields.Time Saved \<= 32)}}8

{{else if(issue.fields.Time Saved \> 32 and issue.fields.Time Saved \<= 52)}}13

{{else if(issue.fields.Time Saved \> 52 and issue.fields.Time Saved \<= 84)}}13

{{else if(issue.fields.Time Saved \> 84)}}21{{/}}

comments: author: Gregory
body: Hello Manoj,

Thanks for your reply.

I didn't mentioned it in the initial post by I also tried the if/else structure as you shared.

Same result, the rule is successfully executed though no value the field V-Impact is always updated with "none".

I'm thinking the value 1,2,3, 5, etc... in the smart value may be seen as "string" while the V-Impact is waiting a "number".

Gregory


author: Manoj Gangwar
body: Ensure that you're referencing the Time Saved custom field correctly. It's best to verify the exact field name and ID (e.g., customfield_12345) by checking the field in Jira. This might look like:

issue.fields\["customfield_12345"\]


author: Gregory
body: Hello Manoj,

Sorry for the late reply.

I tried the solution of using the custom field name and ID, as well as some few other ways to format the "algorithm".

Unfortunately the result is always the same, it ends up with ""none" in the V-Impact field.

I think we will export the data via API to do the computation outside of JIRA.

Thanks anyway.


Tags: automation

cloud

condition

conditional

if

jira-cloud