Here are the steps to reproduce. Pretty sure this may be a bug:
Hi @DOUGLAS THOMPSON
This not messing up, as it is a text field, filled or not
Automation actions using a form field that is always on the form (based on text) it will copy the value in the field.
If there is no information on the field the field still exists, but just with no information (null).
Smart value "exists"
{{exists(smartValue)}} returns true or null
{{exists(smartValue)}}
{{exists("string")}} returns true or null
{{exists("string")}}
So it returns what is in the field or empty, it will no fail.
I wasn't very clear... for the text field, if I do NOT set the default value and the user does not enter anything when completing the form, it comes back as 'false'. If the user does enter something in, then it comes back as 'true', which is what I would expect.
If I DO set the default value, then it comes back as 'true' -- again, what I would expect.
If I delete what I put into the default value (so it's back like it was before), instead of coming back as 'false', it still comes back as 'true'.
If I delete the form component, then put a new one in, and don't touch the default value at all, then it comes back as 'false' (if the user doesn't put anything in the field).
It's as if once that default value is used, then it will ALWAYS come back as 'true', even after the value is deleted and the user leaves it blank.
I just explained this, this is not how this works on a text field.
It will always come back with the input value or as NULL (blank) if no input is done.
... which is exactly why I think there's a bug. If there is no input (i.e. the default value was there but was then deleted), it comes back as having an input value -- not null like you're saying it should. I can test this again, but this is the behavior I observed when running around in circles trying to figure out why it was not working how I expected.
Hello @DOUGLAS THOMPSON and @Marc -Devoteam- , I read through this exchange and decided to settle it with a clean test rather than add another opinion, so here is what I actually did and found.
Setup: fresh text field, key ghosttest, no automation if/else (avoided a syntax mismatch on this instance), just a direct print of the smart value:
ghosttest
if/else
EXISTS RESULT: {{exists(forms.last.ghosttest.trim)}} RAW VALUE: [{{forms.last.ghosttest.trim}}]
The test sequence, matching your matrix, Douglas:
exists
HELLO
exists()
EXISTS RESULT: false
RAW VALUE: []
No ghost value at any point. The smart value engine returned exactly what it should on a genuinely empty field, whether the emptiness came from a cleared default or a freshly recreated field.
So on my instance, Marc's explanation holds up under a real test, not just in principle. exists() reflects whatever is actually stored, with no memory of a prior default.
Douglas, since your result differs from a clean reproduction, one thing worth checking that could explain it: are you testing exists() on the exact same expression path I used (forms.last.<key>.trim), or is there a different smart value in play, forms.first, a different form on the same issue, or the field referenced without .trim? A trailing space or a stale forms context (referencing an older submission rather than forms.last) would produce exactly the symptom you described. If you can share your rule's actual smart value line, that would likely surface the difference in seconds.
forms.last.<key>.trim
forms.first
.trim
forms
forms.last
I truly appreciate the feedback and input.Mine is just like yours Sami(forms.last.field-key.trim)For your #3, after deleting the default value and submitting blank, I would expect the result to be 'false', but it's 'true'. It seems there is no way to get the field back to the original 'false' test result without deleting the field entirely and recreating it.What I would like to do with a form is put in default values, run some tests, then remove the default values so that 'exists' reverts to seeing the field as 'false'. Instead, here's what happens:
+----------------------------+--------------------+----------------+| Form Field Default Value | Exists on No Value | Expected Value || Set | | |+----------------------------+--------------------+----------------+| No | false | false || Yes | true | true || No (text deleted) | true | false |+----------------------------+--------------------+----------------+
And maybe I should just be doing my automation differently and there's something better to use than 'exists'. I just thought by deleting the default value, it would revert back to the same 'false' condition as before when the field was first created. As mentioned, there seems to be no way to ever get 'exists' to be false again without destroying the field and recreating it.
@DOUGLAS THOMPSON you were right, and I owe you and the thread a correction. I reran this properly and reproduced your row 3 exactly.
First, the correction. My earlier "clean" test was measuring nothing: I had the rule on the Issue created trigger, and per Atlassian's own documentation, forms.last.* smart values are only populated when the rule uses the Form submitted trigger. Every result I posted yesterday came from an empty namespace, which is why it all read false / [] regardless of the field. My apologies for the confident-sounding wrong answer.
Issue created
forms.last.*
Form submitted
false / []
The real test, on the Form submitted trigger:
[HELLO]
[]
Why it happens: clearing the text out of a default value box leaves the field holding an empty string, not a null. exists() tests presence, not content, so an empty string counts as present. A field that never had a default holds null, which is why a freshly recreated field returns false. You did not misread anything; exists() is the wrong tool for this question.
The fix is to test for content instead of presence. Replace the exists() check with an emptiness check on the trimmed value:
{{#if(not(equals(forms.last.field-key.trim, "")))}}Field Name: {{forms.last.field-key.trim}}{{/}}
Tested on my side in three cases: a real default value fires, a cleared default prints nothing, and a value the user types into a no-default field fires. That treats "" and null identically and gives you the behaviour you wanted all along, with no need to delete and recreate fields.
@Marc -Devoteam- your point that the field still exists with no information was correct in principle; the twist is that "no information" after clearing a default is an empty string rather than null, and exists() distinguishes the two. Good thread, and a genuinely useful gotcha for anyone mixing defaults with automation conditions.
Thank you @Sami Shaik and @Marc -Devoteam- . I will do some testing and transition away from using "exists".
It looks like you're new here. Sign in or register to get started.