Custom Picker selection incorrectly populating field

Certified Associate Developer

Hello,

I'm working with a custom picker that should allow one selection. A different selection should be made by removing the first selection. 

Currently, when a user types, makes a selection, and then keeps typing, the input is filled with 50 seemingly random selections. These selections do not save. 

When typing slower and allowing the dropdown to fully load, it works as wanted. Any ideas on how to fix this? Thank you

 a!pickerFieldCustom(
                label: "Name",
                labelPosition: "ABOVE",
                placeholder: "--- Select a Name ---",
                saveInto: local!selectedPerson,
                suggestFunction: rule!AST_GETNAMES,
                selectedLabels: if(
                  a!isNullOrEmpty(local!selectedPerson), 
                  null, 
                  index(rule!AST_GETUSERFROMARRAY(suggestionText:local!selectedPerson), "data")
                ),
                value: if(
                  a!isNullOrEmpty(local!selectedPerson), 
                  null, 
                  index(rule!AST_GETUSERFROMARRAY(suggestionText:local!selectedPerson), "data")
                ),
                required: true,
                validations: {},
                disabled: false,
                maxSelections: 1, /* Only allow one name to be selected at a time */
              ),

  Discussion posts and replies are publicly visible

Parents
  • Check the output of this rule....

    rule!AST_GETUSERFROMARRAY(suggestionText:local!selectedPerson)

    I think that it's returning that 50 random selections....

  • 0
    Certified Associate Developer
    in reply to David Jimenez Calleja

    Thank you, I've been looking there and I'm not seeing the issue. If you have a chance to take a look, I'd really appreciate it. 

    a!localVariables(
      local!query: if(
        or(
          isnull(ri!suggestionText),
          length(ri!suggestionText) = 0
        ),
        null, /* If suggestionText is empty or null, no query filters will be applied */
        a!queryLogicalExpression( 
          operator: "AND",
          filters: {
            a!queryFilter(
              field: "name",
              operator: "=",
              value: lower(ri!suggestionText[1]) /* Safeguard: Accessing the first element safely */
            )
          },
          ignoreFiltersWithEmptyValues: true
        )
      ),
      local!pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: 50
      ),
      local!result: a!queryEntity(
        entity: cons!DLP_ed_person_constant,
        query: a!query(
          logicalExpression: if(
            isnull(local!query),
            a!queryLogicalExpression(operator: "AND", filters: {}), /* Empty logical expression if query is null */
            local!query
          ),
          pagingInfo: local!pagingInfo
        ),
        fetchTotalCount: false
      ),
      a!dataSubset(
        data: if(
          isnull(local!result),
          {},
          a!forEach(
            items: local!result.data,
            expression: fv!item.displayName & " (" & fv!item.email & ")"
          )
        ),
        identifiers: if(
          isnull(local!result),
          {},
          a!forEach(
            items: local!result.data,
            expression: fv!item.name
          )
        )
      )
    )

Reply
  • 0
    Certified Associate Developer
    in reply to David Jimenez Calleja

    Thank you, I've been looking there and I'm not seeing the issue. If you have a chance to take a look, I'd really appreciate it. 

    a!localVariables(
      local!query: if(
        or(
          isnull(ri!suggestionText),
          length(ri!suggestionText) = 0
        ),
        null, /* If suggestionText is empty or null, no query filters will be applied */
        a!queryLogicalExpression( 
          operator: "AND",
          filters: {
            a!queryFilter(
              field: "name",
              operator: "=",
              value: lower(ri!suggestionText[1]) /* Safeguard: Accessing the first element safely */
            )
          },
          ignoreFiltersWithEmptyValues: true
        )
      ),
      local!pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: 50
      ),
      local!result: a!queryEntity(
        entity: cons!DLP_ed_person_constant,
        query: a!query(
          logicalExpression: if(
            isnull(local!query),
            a!queryLogicalExpression(operator: "AND", filters: {}), /* Empty logical expression if query is null */
            local!query
          ),
          pagingInfo: local!pagingInfo
        ),
        fetchTotalCount: false
      ),
      a!dataSubset(
        data: if(
          isnull(local!result),
          {},
          a!forEach(
            items: local!result.data,
            expression: fv!item.displayName & " (" & fv!item.email & ")"
          )
        ),
        identifiers: if(
          isnull(local!result),
          {},
          a!forEach(
            items: local!result.data,
            expression: fv!item.name
          )
        )
      )
    )

Children
No Data