Used to help users avoid creating duplicate entries for a given entity, for example two members with the same personal identity number.
The control looks like a normal textbox but when its value is changed it calls the control's stored procedure, which can choose to show a prompt offering to forward the user to another menu item.
The textbox with redirect in it's initial state.
If the user enters a value that is deemed a duplicate, then you can display a forward message (if you want), and then the user will be redirected to another page. Presumably, in this case, a page showing the customer that the user entered.
You can also display an error message without redirecting, if entering a duplicate value is considered invalid.
Called when the textbox's value is changed.
CREATE OR ALTER PROCEDURE dbo.PIN_TextboxWithRedirect @Value varchar(max) = NULL AS BEGIN DECLARE @PersonId int = (SELECT PersonId FROM Person WHERE PIN = @Value); IF @PersonId IS NULL RETURN; -- Not a duplicate. SELECT CONCAT( 'A person with PIN ', @Value, ' is already registered. Do you want to view the existing entry?' ) AS Prompt, 'View' AS OkButtonText, 123 AS ForwardMenuItemId, -- Passingfields. @PersonId AS PersonId; END