Custom picker for dummies

I've been trying to figure out step by step how to create my own address picker.

Most of the questions I've run into here are too specific and don't cover basics. Also, I didn't find an example or tutorial in the online Appian course for this topic.

So, please help! Slight smile

This is my case:

Simple address table example (table has some more columns but I believe they are irrelevant for this story):

ID : 1
ADDRESS_TEXT_ID: "3RD AVENUE-15-NEW YORK-55555"

ID : 2
ADDRESS_TEXT_ID: "5TH AVENUE-10A-LOS ANGELES-12345"

ID : 3
ADDRESS_TEXT_ID: "UPPER STREET-14-AUSTIN-52154"

What I need is a picker that starts searching my address database table with rows like those above after I type at least 3 characters. It allows only 1 selection that needs to be represented with address text (label) and stored as its numerical ID in rule input (rule input is CDT, so the input field should be ri!employee.addressId). 

This is the rule I've created for search:

a!queryEntity(
  entity: cons!EEDM_ADDRESS_DATA_STORE_ENTITY,
  query: a!query(
    logicalExpression: a!queryLogicalExpression(
      operator: "AND",
      filters: {
        a!queryFilter(
          field: "addressTextId",
          operator: "includes",
          value: upper(ri!searchText)
        )
      },
      ignoreFiltersWithEmptyValues: true
    ),
    pagingInfo: a!pagingInfo(
      startIndex: 1,
      batchSize: 50
    )
  ),
  fetchTotalCount: false
).data

This is my custom picker code now:

a!pickerFieldCustom(
  label: "Pick address",
  labelPosition: "ABOVE",
  instructions: "",
  helptooltip: "Start typing address text ID and address containing input string will be shown",
  placeholder: "---Type address text ID ---",
  maxselections: 1,
  suggestfunction: rule!EEDM_SearchAddressByString(_),
  value: ri!employee.addressId,
  saveInto: ri!employee.addressId,
  validations: {}
)

I know I'm missing some key properties but I don't get how to define them.

Could anyone give me step by step example how to finish this picker?

  Discussion posts and replies are publicly visible

Parents
  • Hi Ivan

    You'll need to break this down a little bit more. The Custom Picker field needs to have a couple of rules to support it:

    • one to perform the actual search - so you start typing in your search text and the suggest function returns the candidates, and when you select one of them it stores the relevant identifier in the ri!employee.addressId. I think you've got that pretty well covered
    • the a!pickerFieldCustom() also needs to display a label for the item you've picked. This label will be held in the 'selectedLabels' attribute. So you'll need another rule to fetch the data based upon the addressId that you've stored in order to return the relevant label
    • in terms of only triggering the search when you've keyed in > 3 characters you can do that in the your suggestFunction by returning any empty datasubset until the user has keyed in > 2 characters
Reply
  • Hi Ivan

    You'll need to break this down a little bit more. The Custom Picker field needs to have a couple of rules to support it:

    • one to perform the actual search - so you start typing in your search text and the suggest function returns the candidates, and when you select one of them it stores the relevant identifier in the ri!employee.addressId. I think you've got that pretty well covered
    • the a!pickerFieldCustom() also needs to display a label for the item you've picked. This label will be held in the 'selectedLabels' attribute. So you'll need another rule to fetch the data based upon the addressId that you've stored in order to return the relevant label
    • in terms of only triggering the search when you've keyed in > 3 characters you can do that in the your suggestFunction by returning any empty datasubset until the user has keyed in > 2 characters
Children
No Data