I am trying to create an automation rule to comment on issue when an issue is transitioned to Done status. In the comment, automation will post the following:
TextField_A: <Value_1>
TextField_B: <Value_2>
TextField_C: <Value_3>
However, in TexField_C it does not always have a value so I would like it to specify it as None instead of blank -> TestField_C:
May I know how do I achieve this?
I've tried using the following smart values and couldn't get it to work:
{{issue.customfield_ID.value.replace("null","None")}}
{{issue.customfield_ID.replace("null","None")}}
{{issue.customfield_ID.value.replace(" ","None")}}
{{issue.customfield_ID.replace(" ","None")}}
Thanks.
Hi and welcome to the Atlassian Community!
You could try and solve this with a variable an SmartValue with condition:
The variable creation looks like this:
{{if(exists(issue.TextField_C),issue.TextField_C, "None")}}
And in the UI:
In the last step I logged out the value of the variable and saw it behaved as you would expect.
Give it a try!
Jeroen
Thank you everyone for the guidance. Managed to get it to work now.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Kelvin Teng -- Welcome to the Atlassian Community!
In addition to the other answers provided...
For automation rules, at least three things impact how to supply a value when the field is considered empty:
For the first one, newly created issues may reach rules in an unstable state due to racetrack errors, leading the entire field / smart value to be missing. The symptom for this is often a rule error indicating the field is not present for the issue type. The fix for that is to use the Re-fetch Issue action after the rule trigger and before performing the empty field check.
Next, the field type impacts the technique needed, because the exist() function does not work for all types. Understanding how the fields are stored in the smart values helps to learn how to test for empty values for each type. This is particularly tricky for nested structures, such as the Fix Version, Sprint, and similar fields.
Lastly, some field types, once ever set with a value, appear to have an "empty string" versus "null", and exists() only tests for null. I recall defects logged for this symptom, and potential work-arounds are noted below.
Additional checks / workarounds are:
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Kelvin Teng - I believe this should do the trick:
TextField_C: {{#if(not(exists(issue.customfield_ID)))}}None{{/}}{{issue.customfield_ID}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ha! I had a similar answer to @Jeroen Poismans :-}
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.