Hi every one, do u know about the sandbox downloas number generator right? But i’ve got this error when i put the assign button in my own application. I’ve got a lot more mistakes too. Can anyone please help me. I am very new to this. Thanks
I haven’t looked at the download you mention, but the problem is that GenerateSequentialNumber is not a built-in function in LotusScript. You have to also copy the function definition, not just the button that calls the function. The function probably also uses a view that you will need to copy.
It sounds like you might need to learn quite a bit more about LotusScript before you attempt this application.
Description: * This code goes in the “Initialize” event of an agent, set to
run if documents have been created or modified, and on newly
modified documents. The field that is updated is called
"number" and is an editable text field. The default value of
the "number" field is @If(number = "" ; "TBA" ; number). A
hidden view and profile documents are also used.
This agent is good up to 99,999 documents that contain the
field "number".
Code: *
Sub Initialize
Dim Session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim ProfileDoc As NotesDocument
Dim doc As NotesDocument
Dim item As NotesItem
Dim item2 As String
Dim Nitem As NotesItem
Dim Nitem2 As String
Dim num As Integer
Dim NumStr As String
Dim docnum As Integer
Dim TBAnum As Integer
Dim initialnum As Integer
Set db = Session.CurrentDatabase
Set view = db.GetView("HiddenViewName")
Set ProfileDoc = db.GetProfileDocument("ProfileDocName")
Dim maildoc As NotesDocument
Set maildoc = New NotesDocument(db)
Dim mailitem As NotesItem
Call db.UpdateFTIndex(True)
docnum = view.FTSearch("*",0)
TBAnum = view.FTSearch("TBA",0)
NumStr = ProfileDoc.nextid(0)
If NumStr = "" Then
initialnum = docnum - TBAnum
num = initialnum
Else
num = Cint(NumStr)
End If
ProfileDoc.nextid = Cstr(num)
Call ProfileDoc.save(False,False)
If TBAnum > 0 Then
For i = 1 To TBAnum
Set doc = view.GetNthDocument(i)
Set item = doc.GetFirstItem("number")
item2 = item.text
If item2 = "TBA" Then
num = num + 1
If num < 10 Then
newnum = "0000" & Cstr(num)
Elseif num < 100 Then
newnum = "000" & Cstr(num)
Elseif num < 1000 Then
newnum = "00" & Cstr(num)
Elseif num < 10000 Then
newnum = "0" & Cstr(num)
Elseif num < 100000 Then
newnum = "0" & Cstr(num)
Else
newnum = newnum
End If
doc.number = newnum
Call doc.save(False,False)
ProfileDoc.nextid =Cstr(num)
Call ProfileDoc.save(False,False)
End If
Next
End If
Thank u every one. Thanks for answering my questions. I’m going to try that man. BT, u’re right man, i need to learn more. Thanks And GOd bl;ess u guyz