Custom picker for Searching users

Hi,

I have a requirement to create a search filed for searching users List. The users list is getting from an Query Rule(table from DB) not from any groups.

I have achieved this by using the following code.

Code:

a!pickerFieldCustom(
label:"Select Re-assignee",
maxSelections:1,
suggestFunction: rule!ucArrayPickerFilter(
filter:_ ,
labels: local!reassignChoiceLabel,
identifiers: local!reassignChoiceValue
),
selectedLabels:a!forEach(
items: local!selectedAssignee,
expression: index(touniformstring(local!reassignChoiceLabel), wherecontains(fv!item, touniformstring(local!reassignChoiceValue)))
),
value:local!selectedAssignee,
saveInto:local!selectedAssignee,
labelPosition:"ADJACENT",

)

-----------------------------------------

rule using in the suggest function

rule: ucArrayPickerFilter

I'm getting the user's list while searching with User Names(below snippet) but my requirement is, i should get users list even if we search with an user id (both user name and user id should work).

 

Please suggest.

Thanks in advance

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Do you plan to always query the entire list of users into a local variable and pass the entire list into ucArrayPickerFilter?  That won't perform very well if the users database is planned to grow even somewhat large.  Usually the way to do this would be to have the picker actually query into the users table live while the user enters search terms.  Then (to satisfy your use case) you'd be able to use QueryLogicalExpressions to allow searching via different values, i.e. the person's actual name, username, id, etc.

  • Could you please explain in details with an example query Logic expression.. Thank you in advance. Slight smile

  • 0
    Certified Lead Developer
    in reply to Harris

    Here's a simple version.  This will allow the end user to type a partial first name OR partial last name OR partial username, OR the user ID.  The first and last names must begin with the search string, but the search string can match any part of the username.

    a!queryLogicalExpression(
      operator: "OR",
      filters: {
        a!queryFilter(
          field: "firstName",
          operator: "starts with",
          value: ri!input
        ),
        a!queryFilter(
          field: "lastName",
          operator: "starts with",
          value: ri!input
        ),
        a!queryFilter(
          field: "username",
          operator: "includes",
          value: ri!input
        ),
        a!queryFilter(
          field: "userId",
          operator: "=",
          value: tointeger(ri!input),
          applyWhen: not(isnull(tointeger(ri!input)))
        )
      }
    )

Reply
  • 0
    Certified Lead Developer
    in reply to Harris

    Here's a simple version.  This will allow the end user to type a partial first name OR partial last name OR partial username, OR the user ID.  The first and last names must begin with the search string, but the search string can match any part of the username.

    a!queryLogicalExpression(
      operator: "OR",
      filters: {
        a!queryFilter(
          field: "firstName",
          operator: "starts with",
          value: ri!input
        ),
        a!queryFilter(
          field: "lastName",
          operator: "starts with",
          value: ri!input
        ),
        a!queryFilter(
          field: "username",
          operator: "includes",
          value: ri!input
        ),
        a!queryFilter(
          field: "userId",
          operator: "=",
          value: tointeger(ri!input),
          applyWhen: not(isnull(tointeger(ri!input)))
        )
      }
    )

Children
No Data