Control: Textbox with redirect

 Show all Hide all

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.

Start value:
Return value:

Control container: NewEdit

Supported in: NewEdit

SQL

SQL Call: Redirect (mandatory)

Called when the textbox's value is changed.
Supports custom errors: No
May modify database: No

Parameters:

@Value mandatory string
The value in the textbox.

Resultset: Forwarding

Repeat mode: repeated zero or one time
Row count: exactly one row

Columns:

<xxx> optional string
Any column with no other specific meaning will pe passed on to the menuitem you are forwarding to.
ADMIN_Message optional string
If present and non-null, displays an error message to the user instead of redirecting.
CancelButtonText optional string
Changes the text of the Cancel button.
ForwardMenuItemId mandatory int
Menu item to forward to.
OkButtonText optional string
Changes the text of the OK button.
Prompt mandatory string
Message to show the user before forwarding.

Examples

Prevent duplicate personal identity numbers

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