Skip to main content
alexanderf022406
September 5, 2025
Question

Use customPickerField with googleMaps

  • September 5, 2025
  • 7 replies
  • 0 views

Hello, I am trying to implement a custompickerField, but I still don't understand very well how the suggestFunction and selectedLabels work since I have my DP_addressSugestion rule that receives the address and through the Google Maps API it already returns the filtering. Here is my suggestFunction.

a!localVariables(
  local!addressSugestion: rule!DP_AddressGoogleMaps(
    address: ri!address,
    latitud: -9.5,
    longitud: -75
  ),

  if(
    local!addressSugestion.success,
    a!localVariables(
      local!labels: a!forEach(
        items: local!addressSugestion.result.places,
        expression: index(fv!item, "description", null)
      ),
      local!values: a!forEach(
        items: local!addressSugestion.result.places,
        expression: index(fv!item, "description", null)
      ),

      a!dataSubset(
        data: local!labels,
        identifiers: local!values,
      )
    ),
    a!dataSubset(
      data: {},
      identifiers: {},
      totalCount: 0
    )
  )
)

Please help me to understand or some advices to work it

7 replies

harshas2775
September 5, 2025

Are you getting any error? Also can you share the picker field code as well?

alexanderf022406
September 5, 2025

a!pickerFieldCustom(
      label: "pon tu direccion papi",
      value: local!origin,
      saveInto: local!origin,
      suggestFunction: rule!DP_addressSugestion(
        address: local!origin
      ),
      selectedLabels: local!origin,
      maxSelections: 1
    ),

Here is my pickerField code

 and in the image there is the result of my suggestionFunction

harshas2775
September 5, 2025

Your suggest function configuration looks off. Can you refer to a example pattern here and make similar changes. Then share if you get stuck somehwhere! 

stefanhelzle0001
September 5, 2025

Can you describe what you expect the code to do, and what it is actually doing?

alexanderf022406
September 5, 2025

Hi everyone, I solved by myself, thanks

mikes0011
Brainy
September 5, 2025

Can you share any details of what the issue ended up being, and what you did to fix it, for other users finding this thread in the future with similar issues?

alexanderf022406
September 5, 2025

No problem. As the documentation says, suggestionFunction requires a function that executes a filtering or search rule for a certain array, and this function returns a datasubset with data and identifiers. In the case of Google Maps, this is much simpler since the API does the filtering for you, so you don't need to do much work. I'll leave the code for the ruleExpression and the interface.

a!localVariables(
  local!addressSugestion: rule!DP_AddressGoogleMaps(
    address: ri!address,
    latitud: - 9.5,
    longitud: - 75
  ),
  if(
    local!addressSugestion.success,
    a!dataSubset(
      data: a!forEach(
        items: local!addressSugestion.result.places,
        expression: index(fv!item, "description", null)
      ),
      identifiers: a!forEach(
        items: local!addressSugestion.result.places,
        expression: index(fv!item, "description", null)
      ),
      
    ),
    a!dataSubset(data: {}, identifiers: {}, totalCount: 0)
  )
)

a!pickerFieldCustom(
      label: "Direccion Asistencia",
      suggestFunction: rule!DP_addressSugestion(address: _),
      selectedLabels: local!origin,
      value: local!origin,
      saveInto: { local!origin },
      maxSelections: 1
    )