Meaning of underscore( _ ) in a!pickerFieldCustom Component

Certified Associate Developer

I have a question while using the a!pickerFieldCustom Component example in Document.

a!localVariables(
  local!pickedState,
  local!stateLabels: { "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming" },
  local!stateAbbreviations: { "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY" },
  a!pickerFieldCustom(
    label: "State of Residence",
    instructions: "Value saved: " & local!pickedState,
    placeholder: "Type to select the employee's state of residence",
    maxSelections: 1,
    suggestFunction: rule!ucArrayPickerFilter(
      filter:_ , 
      labels: local!stateLabels, 
      identifiers: local!stateAbbreviations
    ),
    selectedLabels: a!forEach(
      items: local!pickedState,
      expression: index(local!stateLabels, wherecontains(fv!item, local!stateAbbreviations))
    ),
    value: local!pickedState,
    saveInto: local!pickedState
  )
)

I wonder what the meaning of underscore ( _ ) in line 11 in this code.

Below is a link to the page I referenced.

https://docs.appian.com/suite/help/21.3/recipe-configure-an-array-picker.html

  Discussion posts and replies are publicly visible

Parents
  • The technical term for the underscore is partial evaluation. It used to be something that was used pretty frequently in Appian. For example, the precursor to the a!forEach() function was called apply() and it often required using an underscore. However, with the introduction of newer functions, I believe this is the only place remaining that still uses an underscore.

    Basically its purpose is that it allows you to evaluate the function without having that value defined yet. So if you add an underscore to the filter, it tells Appian that it doesn't need a value for that to render the component. However, once it does have a value for what the user typed in, this value will be inserted into the location where the underscore is provided and re-evaluated with the search text.

Reply
  • The technical term for the underscore is partial evaluation. It used to be something that was used pretty frequently in Appian. For example, the precursor to the a!forEach() function was called apply() and it often required using an underscore. However, with the introduction of newer functions, I believe this is the only place remaining that still uses an underscore.

    Basically its purpose is that it allows you to evaluate the function without having that value defined yet. So if you add an underscore to the filter, it tells Appian that it doesn't need a value for that to render the component. However, once it does have a value for what the user typed in, this value will be inserted into the location where the underscore is provided and re-evaluated with the search text.

Children
  • 0
    Certified Associate Developer
    in reply to Peter Lewis

    Thank you for the reply. It helped me understand.

  • Hi ,

    I am trying achieve the same with above with extra requirement. Control the length of the search from the  picker. If the length of the filter less than 2 (len(ri!filter)<2) i am trying not to query from the queryentity.Can u please Help me with this.I am getting  below.Invalid index: Cannot index property 'data' of type String into type List of Variant after adding condition to the rule to fetch the data for picker component.

    if(or(rule!APN_isBlank(ri!filter),and(not(rule!APN_isBlank(ri!filter)),len(ri!filter<2))),
    {},
    with(
    local!output: a!queryEntity(
    --filters to apply based on search
    ).data,
        local!matches: union(local!output, local!output),
        a!dataSubset(
          data: index(
            local!matches,
            ri!pickerDisplay,
            {}
          ),
          identifiers: index(
            local!matches,
            ri!identifier,
            {}
          )
        )
      )
    ))

  • I would suggest to start a new thread with your issue as it is a bit different, and this thread is almost a year old.

    Otherwise before doing so l  would recommend to:

    - Update your with() function as it has been superseded by a!localVariables()

    - reduce the if() statement to if(len(ri!filter)<2.., as len() operates successfully on null or empty values