EdHayes3
EdHayes3

Reputation: 1953

Force Oracle APEX Text Field with Autocomplete to have result

In Oracle APEX, I have a Text Field with Autocomplete. I want to force the item to have an autocomplete result, without using a plugin/add-in.

Best attempt I made:

  1. Text field with Autocomplete (EMPLOYEE_NAME) Has list of values attached to it.
  2. Hidden field (VALIDATED_FLAG) = FALSE
  3. Hidden field (EMPLOYEE_ID)
  4. Dynamic Action, when change on EMPLOYEE_NAME, set VALIDATED_FLAG = FALSE.
  5. Dynamic Action, when custom; result, on EMPLOYEE_NAME, set EMPLOYEE_ID based on SQL with input of EMPLOYEE_NAME. Also, set VALIDATED_FLAG = TRUE.
  6. Dynamic Action, when Lose Focus on EMPLOYEE_NAME, and VALIDATED_FLAG != TRUE, clear EMPLOYEE_NAME

With this approach, it works when I click the autocomplete result, then tab out of the field. The EMPLOYEE_NAME stays, and the EMPLOYEE_ID field gets updated.

But it doesn't work when I press Enter to select the autocomplete result, then tab out of the field. The EMPLOYEE_ID field changes, but the EMPLOYEE_NAME field clears.

Upvotes: 0

Views: 4993

Answers (1)

YotamW Constantini
YotamW Constantini

Reputation: 410

you can use the apex select2 plugin which has an inherent autocomplete function, and make sure to mark: "Display Extra Values: no"

https://apex.oracle.com/pls/apex/f?p=64237:20:0:

generally, I don't recommend using server side condition to change user-altered field, but rather add an Execute PL/SQL code dynamic action, returning a flag.

The help text for server-side conditions on dynamic action says: "Select a condition type to be met in order for this dynamic action to be active." While client side conditions determine if the actions fire.

Upvotes: 2

Related Questions