Please help. I have a querysave event in form. the below is the code snippet. It is for calculating a ref number(settlement number) whose format is “ST115-00001”
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim w As New notesuiworkspace
Dim uidoc As notesuidocument
Dim SESS As New NotesSession
Dim RefView As NotesView
Dim DB As NotesDatabase
Dim RefDoc As NotesDocument
Set DB = SESS.CurrentDatabase
Set RefView = DB.GetView("System\AutoNo")
Set uidoc=w.CurrentDocument
Dim approvedcnt As Integer
approvedcnt = Cint(source.fieldgettext("appcnt"))
If uidoc.EditMode = True Then
Financial_Year = Clng(Right$(Cstr(Year(Now)),3)) + 104
If Month(Now) >= 4 Then Financial_Year = Financial_Year + 1
DocKey = Cstr(Financial_Year)& "-"
New_No = 0
Set RefDoc = RefView.GetDocumentByKey(DocKey , True)
If Not(RefDoc Is Nothing) Then New_No = Clng(Right$(RefDoc,5))
New_No = New_No + 1
autono = DocKey & "-" & Right$("00000" & Cstr(New_No) ,5)
Application ="ST"
Latest_No = Application + autono
Call uidoc.FieldSetText("SETTLEMENT_NO",Latest_No)
Call uidoc.Refresh
Else
Exit Sub
End If
get_ex_rate
get_cv_local
Call uidoc.FieldSetText("Flag1", "A")
If approvedcnt = 12 And uidoc.FieldGetText("STATUS") = "APPROVE" Then
Call uidoc.fieldsettext("Flag2", "B")
End If
Dim answer2 As Integer
answer2% = Msgbox("Do you want to save this document?", 1, "Save")
If answer2 = 1 Then
Print "Saving"
End If
If answer2 = 2 Then
continue=False
Exit Sub
End If
uidoc.Refresh
uidoc.close
End Sub
I need the value of DocKey and New_No to be populated to a view. what formula should i use and is my logic correct. please help.
Regards,
Priya.
Your code doesn’t need to get the view, or do anything to populate it. Views populate themselves, by means of a selection formula that determines which documents are displayed, and column formulas that determine what values are displayed for each document. These formulas are edited by opening the specific view in Domino Designer.
If you already have a view that selects the right documents, and that view already has a column for Settlement_No, then you should already be seeing the values like “ST115-00001” in the view. If you have the view already but it is not showing the Settlement_No data, and if that’s the format you want to see the data in the view, then all you need to do is add a column to the view, select “Field”, and select “Settlement_No”.
If what you’re really asking is how to see DocKey and New_No in the view without them being combined, so instead of seeing “ST115-00001” you see “ST115” and “00001”, then you have two choices.
Modify your code to also save DockKey and New_No in the document, and then add two new columns to the view. If you don’t want to add new visible fields to your form, you will want to use the NotesDocument class and ReplaceItemValue in order to save the DocKey and New_No.
Simply to add two view columns, and use @Left(Settlement_No;”-“) in the first column formula and @Right(Settlement_No;”-“) in the second column formula.
Obviously method 2 is simpler, but method 1 has the advantage that you won’t ever have to change it, even if someday you decide to change the formatting of the Settlement_No field so that it looks like this “ST115:00001/more stuff here”.