Workflow steps order

Below is the workflow I want to achieve.
When registering a record, if the same code number has already been registered, a pop-up warning will be displayed and registration will not be possible. If you are not registered, you can register.

This time, I created a workflow like this.
①Click the button
② trigger an event
②-1: Display pop-up only when search for a table each item code contains the input code
②-2: terminate this workflow only when search for a table each item code contains the input code
③Create a new record only when search for a table each item code doesn’t contain the input code

The table has approximately 1,000 records.
It appears that there are too many records and new records are being added before the search is complete.
However, since a trigger is set, trigger processing must finish first.
Currently, the record is registered before the popup, and the popup is always displayed.