GetDocumentByKey - Grabbing Highest Numeric value

I have a button in my document that needs to go to a specific view and grab the highest numeric value from a column, for instance…the view is called “SequenceNumber” with column 1 with the current year and column 2 with a set of numbers (2444,2445,2446). I need to bring back 2446 for 2013 only, as 2446 would also have an entry for 2012, 2011 etc.

How would I set this up? I’m assuming I would use the GetDocumentByKey method for starters. Any direction would be appreciated. Thank you.

Subject: GetDocumentByKey - Grabbing Highest Numeric value

Why not just sort the view and get either first or last document depending on how you sort the column ( do a view refresh defore so you get the true last doc just incase someone else saved a new doc). Once you get the doc and I would suggest incrementing the counter and saving it so you don’t get dups.

Dont forget year rollover code

Subject: GetDocumentByKey - Grabbing Highest Numeric value

One thing you should probably do is read this: http://www-10.lotus.com/ldd/ddwiki.nsf/dx/sequential-numbering.htm

-rich

Subject: RE: GetDocumentByKey - Grabbing Highest Numeric value

Thank you for the link. I will save it for future use. My main concern here is to make sure I get the latest (highest number) from the view into a variable I can use on the current document. The view is sorted descending, which will work for me.

There is already script written out that runs the sequential number piece. I don’t have any experience with GetAllDocumentsByKey method, assuming that’s what I need to use. Thank you.

Subject: RE: GetDocumentByKey - Grabbing Highest Numeric value

Here is what you want

Call lview.refresh

Set ldoc = lview.GetFirstDocument

seqnumber = ldoc.whatever_the_field_name_is(0)

seqnumber = seqnumber +1

doc.whatever_the_field_name_is = seqnumber

call doc.save(true,true)

Subject: RE: GetDocumentByKey - Grabbing Highest Numeric value

Beautiful…worked like a charm. Thank you for your assistance!