Set value to Null

Hello All,

Any body have an idea how to set a value to nothing NULL. Also appears that the attachment element place holder can’t be dynamic. Any ideas?

Not sure I understand what you’re trying to do. Can you be a little bit more specific?

Ya Sure,

Basically how to i set the value of a field like a text, date or an attachment (file Type) back to null in the Tables using the change a thing workflow

so for a text, you would just leave the value empty, and that’ll do it. We don’t have a way to make a field empty (that actually never showed up), I’ll think about it.

2 Likes

Thanks, let me know, currently i am deleting the whole thing and starting over.

@emmanuel Is it possible to change a field back to null by having a hidden input that is blank and adding a workflow to make changes to that field by assigning it to the blank input?

Is it a text or a number field? Usually leaving the value blank in the change thing action does it

1 Like

thanks @emmanuel works for me with date field.

Would be nice to have a option in the dropdown to return a text value to a NULL state.

Leaving a field blank like this is usually indicates to me that I forgot to fill it out whereas I want to purposely it out.

1 Like

Dear Emmanual,
Kindly reconsider adding “Is Null” to setting database variables because leaving an empty condition is not a good UI UX, besides in other functions we already use “Is Empty” & “Is not Empty” so why in this case there isn’t a way to set a field Empty or Null? That’s inconsistent.

Kindly review, I just came here because I had the same question and I found the answer but I beileve it’s not the best UI UX way to go.

3 Likes

Disagree. Works fine the way it is right now. The alternative would be just as confusing I think.

Way it is now, a blank expression evaluates null (“is empty”). Seems the most consistent bubble way to do it.

3 Likes

I must ask what may seem like a dumb question. In Bubble, is there any functional difference between null and empty?

In this forum, in some cases the terms seem to be interchangeable and in others, people see them has being distinct.

Are there cases where null differs from empty?

1 Like

I would wait for an answer from a bubble developer but I believe there is no difference.

By the way, here is one more reason why is Empty or “Set to null” should exist for setting a variable.

When I have a variable of another table-type and it’s NOT a list, this model does not work:

image

Because WorkingOnQID is NOT a list, so when I come in another workflow to do something IF this field is empty, it fails during debug to see it empty, because the reference set BEFORE was not removed by this method in the screenshot.

I have overcome this problem by creating the same field as a list, instead of just a single reference. Where in a list I can use REMOVE parameter to make sure reference is removed. Let me know if this is a bug, so I can report it.

It’s most probably a conceptual/logical bug rather than a code bug. Why the user can’t clear a reference field if it’s NOT a list? Maybe because there was an initial development assumption that a user will never nead to clear a single reference. In my case I needed it somehow, because I wanted each user to work only on 1 reference/question at the same time.

My understanding of Bubble’s ‘Empty’ is that it covers several coded possibilities, including null, but not exclusive to null.

For instance. If we:

  1. create a custom state myState and do not set a default value it will meet Bubble’s condition of empty. Similarly…
  2. used a workflow to then set myState to either nothing or…
  3. set it to “”, it will also meet Bubble’s condition of empty.

It’s impossible to say precisely what the three actions above translate to in code. But their equivalent could look something like this:

In order…

  1. var myState; - this now equates to undefined
  2. var myState = null - this now equates to null
  3. var myState = "" - this now equates to blank

In code, you would need to create a condition that tested for these different values / non-values. But Bubble’s empty equates to all of them.

2 Likes

To null a list, you “set list” to [empty expression]

It works with Clear list for me.

Also that! :+1:

Thanks for this explanation. I’d forgotten about undefined.

In practice, I never understood why I should care about these distinctions. For my “practical” purposes, they were all the same. I think I like Bubble’s viewing them as equivalent.

The problem I run into with Bubble is that there are situations where it won’t set a custom state to empty if it’s of type Date. I haven’t gotten back to reproducing it and reporting it as a bug. Maybe today.

I ended up here because I also have a use case to return a date field in db record to null without deleting the record (in my case, I need to archive the date a checkmark was checked, but be able to “undo” that until another condition is met).

@laurence did you ever submit a bug report for this? Leaving it blank, as suggested above, generates an error in bubble’s error list, so definitely doesn’t seem to be what bubble developers intended, and doesn’t work for dates as you noted.

I guess I will have to set it using yet another empty input for now, but I am starting to get a bit frustrated by the number of empty-input hacks that bubble requires for truly basic stuff…