Solved

Get number from view

Posted on 2004-04-06
7
285 Views
Last Modified: 2013-12-18
Can somebody please check what's wrong? I need to get the highest number in my Ticket no view. This view is sorted Desc, so the number on top of the view is always the highest one, after I get that number I need to grab it increment it and assign  this number to the new document. I have this code in Querysave.

Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim Num As String
Set db = session.CurrentDatabase
Set view = db.GetView("Ticket No.")
Set doc = view.GetFirstDocument
doc.seqnum = Num     ' seqnum is the name of the 1st column in Ticket No.
Msgbox Num
If  doc.fld_CDseqnum(0) <> 0 Then    
  ' Increment the sequence number
End If
0
Comment
Question by:cyle
  • 3
  • 2
  • 2
7 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 10768807
   Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim view As NotesView
    Dim doc As NotesDocument
    Dim Num As String
    Set db = session.CurrentDatabase
    Set view = db.GetView("Ticket No.")
    Set doc = view.GetFirstDocument
If doc Is Nothing Then
    Num="1"
Else
    Num= CStr(CInt(doc.seqnum(0)) + 1)
End If        
    doc.seqnum = Num     ' seqnum is the name of the 1st column in Ticket No.
    Msgbox Num
    If  doc.fld_CDseqnum(0) <> 0 Then    
      ' Increment the sequence number
    End If


At least check for doc Is Nothing.
0
 

Author Comment

by:cyle
ID: 10768837
Num= CStr(CInt(doc.seqnum(0)) + 1) ---- This gives me a type mismatch error.
0
 
LVL 14

Expert Comment

by:p_partha
ID: 10768861
msgbox doc.sequnum(0)

It might be a empty string ("")

Partha
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 14

Expert Comment

by:p_partha
ID: 10768864
sorry typo
msgbox doc.seqnum(0)

Partha
0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 150 total points
ID: 10768915
I have some trouble with your original code: where is Num coming from, why is it a String, and why did you have doc.seqnum= Num?

Consider the following (but don't implement it by Cut&Paste!):

    If doc Is Nothing Then
        Num= 1
    Else
        Num= doc.ColumnValues(0) +1
    End If

It's even faster this way. Make seqnum a number, to be used in the first column of the view. If you start testing, do remove all older documents, for they might not have a seqnum-field...
0
 

Author Comment

by:cyle
ID: 10769058
Okey, I got the highest number using bosman's solution, "for 50 points!!!!" I need to FieldSetText this number to the form.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 10772627
I hate FieldSetText and FieldGetText! I think it's not very frequently used, for there is doc.GetItemValue("fieldname")(0) or doc.fieldname (that doesn't work in all cases, e.g. with field that have the name of a reserved LS-word). The advantage of doc.fieldname(0) over uidoc.FieldGetText("fieldname") is that the first will give you the interpreted value of the field, tha latter only the text and you have to do the interpretation yourself: trimming, text-to-number translation, and multiple value splitting. In most cases you will see the following (in lowercase):

dim ws as new notesuiworkspace
dim uidoc as notesuidocument
dim doc as notesdocument
dim v as variant ' assume multiple value field

set uidoc= ws.currentdocument
set doc= uidoc.document
forall v_i in v
    ' do something with v_i
end forall

And, you're welcome!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question