Skip to main content
Known Participant
February 16, 2021
Question

Saving null when selecting placeholder on dropdown

  • February 16, 2021
  • 3 replies
  • 0 views

Let's say I have the following query where the data is being filter based on siteIds

local!estimations: rule!EEP_QE_getEstimations(
    statusId: cons!EEP_VAL_STATUS_ACTIVE,
    columns: {"site_id_fk", "status_id_fk", "estimation_business_id", "id_pk"},
    siteIds: local!selectedSite
  ).data

Now, I'm saving local!selectedSite using a dropdown menu

a!dropdownField(
              label: "Site",
              labelPosition: "ABOVE",
              placeholder: "--- Select a Value ---",
              choiceLabels: local!sites.name,
              choiceValues: local!sites.site_id,
              value: local!selectedSite,
              saveInto: local!selectedSite,
              searchDisplay: "AUTO"
            )

the value of local!selectedSite is null at the start so everything is queried, as expected. If I select a value from the dropdown the data is filtered accordingly. But when I select a value and then I select the placeholder, the query does not return any values. I've checked the value of local!selectedSite and it's null when the placeholder is selected. I've seen this behavior before and my fix has always been to either have another local in the dropdown to save into, check for null and save the correct value(or null) into the filter variable. I can also do the check in the query. Easy fixes but, I'm still wondering why this happens. What causes this behavior with Appian?

Additional notes: siteId parameter in the expression rule is of type integer array, if that matters.

    3 replies

    danny.verb
    Brainy
    February 16, 2021

    Given that siteIds expects an integer array, there's a chance your query rule is trying to filter with a value of {null} which is different than just null or {}

    I recommend making sure you're using a!localVariables so you can view the value of local!selectedSite in the interface designer variables pane.

    joseh0001Author
    Known Participant
    February 16, 2021

    What you say would make sense with the value being {null}. However, I checked and the value was just null. I have a solution for it which is to check for null before filtering the query but I just find it to be a strange behavior. 

    mikes0011
    Brainy
    February 16, 2021
    But when I select a value and then I select the placeholder, the query does not return any values.

    What are you expecting to happen, and why?

    The Expression Guru