Hi Community Members,
I have created two custom fields, customfield_1 (which can store single value from the list - High, Medium, Low) and another customfield_2.
I am trying to populate customfield_2 (number data type) using the Automation based on the values stored in customfield_1.
Automation rule is successfully running without any errors but customfield_2 is not getting populated with the required output value.
Please let me know the correct syntax or any other way that I can achieve the required logic without going for any third party plugins.
Thanks in advance.
Here is the alternate JSON codes tried in Advance field editing:
{ "fields": {
"customfield_2": "{{#if(equals(issue.fields.customfield_1, \"High\"))}}50{{/}} {{#if(equals(issue.fields.customfield_1, \"Medium\"))}}25{{/}} {{#if(equals(issue.fields.customfield_1, \"Low\"))}}10{{/}} {{#else}}0{{/}}"
}
}
-----
{ "fields": {
"customfield_2": "{{#if(equals(issue.fields.customfield_1, "High"))}}50{{/}} {{#if(equals(issue.fields.customfield_1, "Medium"))}}25{{/}} {{#if(equals(issue.fields.customfield_1, "Low"))}}10{{/}} {{#else}}0{{/}}"
}
}
-----
{ "fields": {
"customfield_2": "{{#if(equals(issue.customfield_1, \"High\"))}}50{{/}} {{#if(equals(issue.customfield_1, \"Medium\"))}}25{{/}} {{#if(equals(issue.customfield_1, \"Low\"))}}10{{/}} {{#else}}0{{/}}"
}
}
-----
{ "fields": {
"customfield_2": "{{#if(equals(issue.customfield_1, "High"))}}50{{/}} {{#if(equals(issue.customfield_1, "Medium"))}}25{{/}} {{#if(equals(issue.customfield_1, "Low"))}}10{{/}} {{#else}}0{{/}}"
}
}
Hi @Laxmi Swamy
Welcome to the Atlassian Community!
I would also recommend avoiding using the advanced field json, however I think that the most future proof option is to use the (relatively new) lookup table functionality to define the relationship between the value in customfield_1 and customfield_2.
This allows for up to 200 possible values in customfield_1 in only 3 steps.
Thanks Tommaso, tried the above solution it works like a charm. The only thing I need to cover is if I want to assign '0' value in case if the customfield_1 has blank/empty value (instead of High, Medium, Low values) as it is an optional field for the users to enter.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Laxmi Swamy ,
For this base case you can simply add a default to the smart value, as per this documentation. The value will be output when nothing is returned by relationship.get().
Your edit issue value should now be {{relationship.get(issue.customfield_1)|0}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ahoy ahoy @Tommaso Gionfriddo _Teklada_ This looks like a great place to start on a issue I'm trying to solve. How would you recommend taking this and making it a 3-D lookup?
I have three fields: customfield_1, customfield_2, customfield_3. Each one has a text value (from a dropdown list) that I'd like to turn into a number 1-5 (1-4 for customfield_3): customfield_1.value1 = 1, customfield_1.value2 = 2, etc.
After finding the number for each custom field, I'd like to add them together to get a composite score: customfield_1.score + customfield_2.score + customfield_3.score = customfield_4
My end goal is for that customfield_4 to then have its own lookup table (or if/else statement) that sets a Priority dropdown based on the score range: 3-5 = Critical, 6-8 = High, etc.
Thank you for any help and thoughts. :)
Kirk
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Laxmi Swamy
Can I recommend something a bit simpler? Rather than putting the code directly into the JSON, use more of the visual aspects to create automation flows. Here is what I would do for your solution.
Following this your customfield_2 will be updated :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To supplement @Jovin suggested, can you verify that the customfield2 is exposed to your project in question (meaning the context for the custom field is configurated properly).
I would recommend the triggering event should be "Field value changed" for all issue operations. In your rule, then setup the If/else condition to check for customfield1 value and then edit issue option to set the customfield2 value.
Hope this also helps.
Best, Joseph Chung Yin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Joseph, I will use the same. Does it also covers the use case for Issue Creation as well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It should. However, you may want to add "Re-fetch issue data" action before your edit issue action.
Hope this helps. If my suggestion helped you, please click on "Accept answer" when you have a chance, so others with similar asks will see this posting as an answered one.
Best, Joseph
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.