Hello, I have a stored procedure in SQL that i would like to call from a Forms Lookup rule. The SP generates a random string for a password. I want the lookup rule to fill the password field in my form with that string.
Here is the Stored Procedure
USE [Laserfiche_XXXX]
GO
/****** Object: StoredProcedure [dbo].[GeneratePassword] Script Date: 5/13/2025 2:44:46 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[GeneratePassword]
-- random string generator
@characterSet varchar(64) = '0123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ@#$&%' --character set
, @randomString nvarchar(9) OUTPUT -- the size should be >= the max length required
, @onechar nvarchar(1) -- one character
, @i int = 0 -- counter
, @r int = 0 --random int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
While @i <= 8 -- put (max length - 1) here it's 10
begin
set @r = floor(rand() * LEN(@characterSet))
set @onechar = SUBSTRING(@characterSet, @r,1)
set @randomString = concat(@randomString, @onechar);
set @i = len(@randomString)
end
END