Environment Variable as Default Value?

Options
Georges Duverger
Georges Duverger Trusted Xano Expert
Just to confirm an assumption I'm making: there is no way to reference an Environment Variable as the Default Value of an input, correct? I'm using the same default value in a few endpoints and I was hoping to have the option to change them all in one place.
[environment_variable_default_value.png]

Comments

  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
     using the environment variable there is not supported currently.

    I would recommend setting that input to nullable and then any time you reference that variable, you can use the "first_notnull" filter and put the environment variable in there.

    Or if you use that input in a lot of places, then switch to a variable at the top so you only do the filter one time.

    var days = input:days|first_notnull(env:default_days)
  • Georges Duverger
    Georges Duverger Trusted Xano Expert
    Options
     Oh, that's a good solution. I'll give it a try. Thanks.
  • Georges Duverger
    Georges Duverger Trusted Xano Expert
    Options
     I wasn't able to use the first approach because the place where I need to use that default value doesn't allow for a filter. I guess it's because I'm already in a filter (see screenshot).
    [no-filter-available.png]
    That said, the second approach of creating a variable at the top with the `first_notnull` filter worked well. 💪
  • Sean Montgomery
    Sean Montgomery Administrator

    ADMIN

    Options
    ah... yea the SQL filters aren't as flexible yet as the standard function stack filters. The UI looks the same but it's different engines behind the scene. We'll get there though!

    Glad the 2nd option worked.