How do I handle empty fields?

Options

I make an external call (bubble) to retrieve records then use that data to write new records in Bubble. Sometimes the fields are empty and that should be okay but I get 500 Internal Server Error when that happens. How do I allow the fields to be empty?

Best Answer

  • MattLaro
    MattLaro Member ✭✭
    edited March 2023 Answer ✓
    Options

    Oh :) now I understand.

    For optional fields, get filter will be your best friend! … even if it requires a tad more effort to implement.

    Explanation

    The dot notation to reference a variable field (object.field) is picky in the sense that it should only be used if you're absolutely and positively sure that the field exists.


    If you're working with a variable that may or may not contain the filed, I suggest using a get filter. The get filter is your awesome failsafe chill buddy that will always return something and, in the worst case scenario, nothing or the value you want it to return.

    Here's an example :

    In your case :

    Using a get filter :

    If we try to add something in the initial object path :


    And try again :

    What is also very nice with a get filter is that it's so failsafe on the get portion, it will also work with the dot notation and still does not fail, so you don't need to imbricate get filters to get the target path.

    Let's suppose we have this new object :

    And then we do this :

    It returns :

    Let's say we return the object to it's original values :


    Then try again :

    Hope this helps!

Answers

  • ihayes
    ihayes Member
    Options

    so I tried using the First_Not Empty filter. The problem is that Bubble doesnt send an empty field at all. How do i handle a situation where a field on a particiular record is missing all together?

  • MattLaro
    MattLaro Member ✭✭
    edited March 2023
    Options

    It's hard to answer without providing any information as to how Xano receives and handles the information, but from what I can understand is that you retrieve an array of objects from bubble which is supposed to have 7 fields but if a field is empty, it will NOT include any field that are empty, so returns less fields… yet writing it back to Bubble requires all 7 fields in the object.

    Is that correct?

  • ihayes
    ihayes Member
    Options

    yes…you got it. Happy to share screenshots but didnt know what would help

  • ihayes
    ihayes Member
    Options

    just to be clear, the requirement for all the fields is from Xano and not Bubble. You can see below that I do a series of Sets. If any of the sets are empty, I get a 500 Internal Server Error

  • ihayes
    ihayes Member
    Options

    thanks @MattLaro this very helpful

  • MattLaro
    MattLaro Member ✭✭
    Options

    Oh :) now I understand.

    tl;dr : for optional fields, get filter will be your best friend! … even if it requires a tad more effort to implement.

    Explanation

    The dot notation to reference a variable field (object.field) is picky in the sense that it should only be used if you're absolutely sure and positive that the field exists.


    If you're working with a variable that may or may not contain the filed, I suggest using a get filter. The get filter is your awesome failsafe chill buddy that will always return something and, in the worst case scenario, nothing or the value you want it to return.

    Here's an example :

    In your case :

    Using a get filter :

    If we try to add something in the initial object path :


    And try again :

    What is also very nice with a get filter is that it's so failsafe on the get portion, it will also work with the dot notation and still does not fail, so you don't need to imbricate get filters to get the target path.

    Let's suppose we have this new object :

    And then we do this :

    It returns :

    Let's say we return the object to it's original values :


    Then try again :

    Hope this helps!