LS on the Web - need help with enclosed code

Help! I need to get the following LS code to work on the web - any ideas on how to get it to work?

Function CreateRFSPMTid (session As Notessession, Source As Notesuidocument)

Dim db As notesdatabase

Dim num As Double

Dim numchar As String

Dim numprefix As String

Dim view As notesview         

Dim servername As String

Dim doc As notesdocument

Set db = session.currentdatabase



servername = Mid(db.server,4,8)   ' Get server name to lookup prefix for request number.  

If servername = "" Then   ' Local, set to all 0's

	source.document.RFSPMTID = "00000000"

Else

	Set view = db.getview("AdminLookup")

	Set doc = view.getdocumentbykey("Server ID " & servername)

	If doc Is Nothing Then

		numprefix = "XX"

	Else

		numprefix = doc.Listvalues(0)

	End If

	

	Randomize   ' Seed the random number generator

	num = (999999 * Rnd()) 

	num = num \ 1

	numchar = Right(("00000" & Cstr(num)),6)     ' Pad left with zeros to make 6 character number.

	numchar = numprefix  & numchar                   ' Prepend number with server id

’ Now check for duplicate

	Set view = db.getview("LookupRequestNumber")

	Set doc = view.getdocumentbykey(numchar)

	If Not doc Is Nothing Then       'If number already exists, then generate another random number 

		num = (999999 * Rnd()) 

		num = num \ 1

		numchar = Right(("00000" & Cstr(num)),6)    '  Pad left with zeros to make 6 character number.

		numchar = numprefix  & numchar                    ' Prepend number with server id

	End If

	Set doc = view.getdocumentbykey(numchar)   ' See if the random number already exists.

	If Not doc Is Nothing Then  'If the second random number exists too, then send note to admin and proceed.

		'Call Send_duplicate_message(db,numchar)

	End If     

	source.document.RFSPMTID = numchar          

End If

End Function

Subject: LS on the Web - need help with enclosed code

Laura,

Your code would need to run in a WebQuerySave event (or be in an agent called by this event) in your form and then since NotesUIDocument does not apply, your first lines of code would be…

Dim s As New NotesSession

Dim doc As NotesDocument

Set doc = s.DocumentContext

…where doc is a handle to the web doc submitted by the web user. Everything else can pretty much remain as is.

Ken

Subject: Not really. db.Server will be “” in every case. A WQS agent runs locally.

You need to use NotesSession.UserName to get the servers name. You can also do away with the Random stuff.Use @Unique instead.

e = Evaluate(|@Unique|)

numchar = numprefix  & Right(e(0), 6)                  ' Prepend number with server id



source.document.RFSPMTID = numchar