Hi All,
My form Action button is called create a New Document
Here is the code for the Form Action Button that calls the Function as below
In the below function I need to sort it by category cat_#
before new document is created …Is it possible?
Function Create New Document()
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim uidoc As NotesUIDocument, QuoteUIDoc As NotesUIDocument
Dim doc As NotesDocument, QuoteDoc As NotesDocument
Dim Server As String
Dim Pos As Integer
Dim NewPos As Integer
Dim FieldName As String
Dim rows As Integer
rows = 10 '--- number of rows & columns
Err = 0
VALIDATIONERROR = 4412
msg = "You need to be connected to the Server to Create a Quote." &_
Chr$(13) & Chr$(13) & "Are you currently on-line ?"
flag = Messagebox (msg, MB_ICONQUESTION + MB_YESNO, "On-line Reminder")
If (flag = IDNO) Then
Exit Function
End If
'-----------------------get current document -----------------------------------------------------------
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
Set db = session.CurrentDatabase
Server = doc.QuoteServer(0)
Call session.SetEnvironmentVar ("BDPSQuoteFromPAF","Y")
Call session.SetEnvironmentVar ("BDPSfiscalyear",doc.FiscalYear(0))
'------------------------ compose new document ------------------------------------------------------------------
Set QuoteUIDoc = workspace.ComposeDocument(Server, "Bdps\BDPS Price Quotes.nsf", "Quotes")
If (QuoteUIDoc Is Nothing) Then
Messagebox "Unable to create new document. Make sure you are on-line.", MB_ICONSTOP, "Error"
Call session.SetEnvironmentVar ("BDPSQuoteFromPAF","")
Call session.SetEnvironmentVar ("BDPSfiscalyear","")
Exit Function
End If
Set Quotedoc = QuoteUIDoc.document
'----------------------------- init fields------------------------------------------
Quotedoc.Company = doc.Company
Quotedoc.Address1 = doc.Address1
Quotedoc.Address2 = doc.Address2
Quotedoc.City = doc.City
Quotedoc.State = doc.State
Quotedoc.Zip = doc.Zip
Quotedoc.Country = doc.Country
Quotedoc.AccountExec = doc.srname
Quotedoc.PAFno = doc.PAFno
Quotedoc.WhoCanRead = doc.WhoCanRead
'--- add these fields to get back to this document ---
Quotedoc.PAFunid = doc.UniversalID
Quotedoc.PAFserver = db.Server
For k = 0 To (rows-1)
FieldName = "cat_" + Trim(Cstr(k))
TField = doc.GetItemValue(FieldName)
If TField(0) = "" Then
Exit For
End If
Call Quotedoc.ReplaceItemValue(FieldName, TField )
FieldName = "Desc_" + Trim(Cstr(k))
TField = doc.GetItemValue(FieldName)
Call Quotedoc.ReplaceItemValue(FieldName, TField )
FieldName = "lot_" + Trim(Cstr(k))
TField = doc.GetItemValue(FieldName)
Call Quotedoc.ReplaceItemValue(FieldName, TField )
NewPos = 0
For Pos = 0 To (rows-1)
FieldName = "pr" + Trim(Cstr(k)) + "_" + Trim(Cstr(Pos))
TField = Doc.GetItemValue(FieldName)
If TField(0) = "" Then
Else
FieldName = "pr" + Trim(Cstr(k)) + "_" + Trim(Cstr(NewPos))
Call Quotedoc.ReplaceItemValue(FieldName, TField)
FieldName = "vb" + Trim(Cstr(k)) + "_" + Trim(Cstr(Pos))
TField = Doc.GetItemValue(FieldName)
FieldName = "vb" + Trim(Cstr(k)) + "_" + Trim(Cstr(NewPos))
Call Quotedoc.ReplaceItemValue(FieldName, TField)
NewPos = NewPos +1
End If
Next
Next
Call QuoteUIdoc.reload
Call QuoteUIdoc.refresh
'-------------------------------------------------------------------------------------
uidoc.Close
End Function
Thanks in advance,
ac ac