Skip to main content

Widget UserPicker

The UserPicker widget provides a searchable dropdown interface for selecting one or multiple users from your application's user base. It supports remote search, group filtering, and flexible display options.

Overviewโ€‹

The UserPicker widget renders as an Element UI select component with remote search capabilities. Users can search and select from the application's user directory with real-time filtering and group-based restrictions.

UserPicker Widget
UserPicker Widget

Configuration Propertiesโ€‹

Basic Propertiesโ€‹

Nameโ€‹

  • Description: Display label for the widget
  • Type: String
  • Default: "Select a user"
  • Usage: Appears as the form label above the selection field

Variable/Modelโ€‹

  • Description: The data model variable name that will store the selected user(s)
  • Type: String
  • Required: Yes
  • Format: Must be a valid variable name (e.g., selectedUser, assignedUsers)

Selection Optionsโ€‹

Multiple Selectionโ€‹

  • Property: multiple
  • Type: Boolean
  • Default: false
  • Description: Enable selection of multiple users
  • When enabled: Returns an array of selected user emails
  • When disabled: Returns a single user email string

Clearableโ€‹

  • Property: clearable
  • Type: Boolean
  • Default: false
  • Description: Adds a clear button to remove all selections

User Filteringโ€‹

Groups Filterโ€‹

  • Property: groupes
  • Type: Array of Group Objects
  • Description: Restrict user selection to specific groups
  • Configuration: Select one or more groups from the dropdown
  • API Behavior: Only users belonging to the selected groups will appear in search results

Label Displayโ€‹

  • Property: label
  • Type: String
  • Options:
    • "name": Display user's first name + last name
    • "Email": Display user's email address
  • Default: "Email"
  • Description: Determines how users are displayed in the dropdown options
UserPicker Configuration
UserPicker Configuration

Validation and Visibilityโ€‹

Screen-Based Configurationโ€‹

The title widget supports different configurations for different screens/contexts:

  • Available: Controls widget visibility on the interface
  • Visible: Controls widget visibility on the interface
  • Required: Makes user selection mandatory for form submission
  • Disable: Disables the widget preventing user interaction
UserPicker Basic Validation
UserPicker Basic Validation

Advanced Visibility Conditionsโ€‹

Use JavaScript expressions for complex visibility logic:

UserPicker Advanced Validation
UserPicker Advanced Validation

Style and Appearanceโ€‹

Placeholder Textโ€‹

  • Property: placeholder
  • Type: String
  • Default: "Search for a user..."
  • Description: Placeholder text displayed when no selection is made

Widthโ€‹

  • Property: width
  • Type: String
  • Default: "100%"
  • Examples: "300px", "50%", "auto"
  • Description: Controls the width of the selection field

CSS Classesโ€‹

  • Property: classNames
  • Type: String
  • Description: Custom CSS classes for styling
  • Format: Space-separated class names

Dynamic Classesโ€‹

  • Property: classes
  • Type: JavaScript Object
  • Description: Conditional CSS classes based on form state
  • Usage: Advanced styling based on data conditions
User Picker Style
User Picker Style

Validation Rulesโ€‹

Add custom validation rules beyond basic required validation:

Rule Typesโ€‹

  • Pattern: Regular expression validation
  • Custom: JavaScript function validation
  • Length: Minimum/maximum selection count (for multiple selection)
UserPicker Validation Rules
UserPicker Validation Rules

Usage Examplesโ€‹

Basic Single User Selectionโ€‹

UserPicker Basic Single User
UserPicker Basic Single User

Multiple User Selection with Group Filterโ€‹

UserPicker Multiple User Selection
UserPicker Multiple User Selection

Events and Interactionsโ€‹

onChange Eventโ€‹

  • Trigger: When user selection changes
  • Data Available:
    • SF_input.value: Selected user email(s)
    • SF_input.SF_data: Complete user object(s)
    • SF_input.SF_currentIndex: Current loop index (if in a loop)
UserPicker Action
UserPicker Action

Data Structureโ€‹

Input Data (Selected Values)โ€‹

// Single selection
"user@example.com"[
// Multiple selection
("user1@example.com", "user2@example.com", "user3@example.com")
];

Complete User Objects (Available in SF_data)โ€‹

{
"email": "john.doe@example.com",
"firstName": "John",
"lastName": "Doe",
"_id": "user_id_123",
// Additional user properties
}

API Integrationโ€‹

User Search Endpointโ€‹

  • URL: /api/v1/user
  • Method: GET
  • Parameters:
    • limit: Maximum results (default: 10)
    • groups: Comma-separated group IDs for filtering
    • key: Search query string
    • SF_mode: Application mode parameter

Group Filteringโ€‹

When groups are configured, the API request automatically includes group filters to restrict results to users belonging to the specified groups.

Best Practicesโ€‹

Performance Optimizationโ€‹

  • Use group filtering to reduce search result size
  • Set appropriate search limits for large user bases
  • Consider caching frequently accessed user data

User Experienceโ€‹

  • Provide clear placeholder text indicating the selection purpose
  • Use descriptive labels that match your use case
  • Enable clearable option for better user control
  • Choose appropriate label format (name vs email) based on context

Validation Strategyโ€‹

  • Use required validation for critical selections
  • Implement conditional validation based on form context
  • Provide meaningful error messages for validation failures

Accessibilityโ€‹

  • Ensure proper labeling for screen readers
  • Maintain keyboard navigation support
  • Use semantic HTML through Element UI components

Troubleshootingโ€‹

Common Issuesโ€‹

No Users Appearingโ€‹

  • Check group filter configuration
  • Verify user API endpoint availability
  • Ensure users exist in the specified groups

Selection Not Savingโ€‹

  • Verify model/variable name is correctly configured
  • Check for form validation errors
  • Ensure proper data binding in parent form

Performance Issuesโ€‹

  • Reduce group scope if too many users
  • Implement pagination for large datasets
  • Optimize search query parameters