This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Mar 15, 2015, 3:59 AM
14 Posts
topic has been resolvedResolved

@DbColumn problem

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 9.0.1
  • Role: Developer
  • Tags: @DbColumn limit
  • Replies: 5

I have a simple task of getting the number of newly updated documents in a view since a specific date. The view has a column with a date of the latest update. I am trying to use @DbColumn to fetch that particular column and then loop through the resulting array and check against the specific date. However, some of the views are huge and the resulting array is bigger then 64kb. How do I simply get back these records from my view?

 Csaba

Mar 15, 2015, 12:47 PM
110 Posts
It's difficult to tell what you actually want to achive without a bit of code

Can you post your entire @DbColumn code? Because at the beginning of your explanation you said you're trying to get just the number of newly updated document which to me would result in something like "@Count(@DbColumn(.....))" or "@Elements(@DbColumn(......))".

But at the end you said you want to get back the records from your view which again to me looks like a NotesDocumentCollection. And if it's a NotesDocumentCollection then it's better because you could just get the number of the newly updated documents with a NotesDocumentCollection.getCount().

So which one is it?

UPDATE

Can you try putting the following code in a computed field and see if it displays the correct number of documents that you want? (adjust the code accordingly)

var your_specific_date = @Date(2015, 2, 1); //change this to the last update date that you want
var vw:NotesView = database.getView("testview"); //change this to the name of your view, make sure the first column is sorted
//assuming you want to get the number of documents updated since 'your_specific_date' until today
var range:NotesDateRange = session.createDateRange(your_specific_date, @Today());
var dc:NotesDocumentCollection = vw.getAllDocumentsByKey(range, true);
return dc.getCount().toString();

Mar 16, 2015, 8:58 PM
14 Posts
I get 0 new documents

regardless of what specific date I set even with @Date(1900, 1, 1)

I tried to set different columns to be sorted in the views, but I always get back 0. 

 

Mar 17, 2015, 4:20 AM
110 Posts
I see..

The column that you mentioned is not the first column is it? Hence why you're using @DbColumn..

Well to use the code that I suggest, the column containing the date of the latest update must be the first column in the view and is sorted (doesn't matter ascending or descending). And the underlying field type of the date must be Date/Time (just in case it's not).

I would suggest you create a test view first so as to not disturb your existing view's columns. The test view can have 1 column only if you wish which is the said column so long as the said column is the first column.

Mar 17, 2015, 10:34 PM
453 Posts
Why not use a full text search to return ...

all of the documents after a given date. I do this where I want all of the documents with the [CompletedDate > " + dString + "] where dString is (today - 30 days)

I then run my query through a view

var vw:NotesView = thisAppDB.getView("vwFTSearch")
var n:Integer = vw.FTSearchSorted(qString, 0 , "SortBy" , false, false, false, false );

the vwFTSearch selects only documents with the form = "SomeForm" so if the DB contains a lot of documents with different form names you can simplify the search, also the FTSearch will fail if CompletedDate is null, so I populate the field with a known very early date which I call blankDate and I use (1/1/1970) , the view also contains a column which I call SortBy so the returned documents in the view are sequenced.

and vw contains only the documents selected so you only have to work with docs that meet your selection criteria. My query actually has about 10 different selection statements. I then work through the view and build a sessionScope variable that contains the UNID of each of the documents, I do this because I need to do some reordering of the documents. The use the sessionScope variable as the dataSource for a repeat control. Sound more difficult than it really is. I have tested where the return list is over 1000 documents and it works great. In the actual production DB I doubt the list will be more than 100. 

In any case I would I would think that doing this by @Formula would be less than optimal performance wise. 

 

Mar 19, 2015, 3:37 PM
14 Posts
GetAllDocumentsByKey works now

Thanks Baxter and Bill.

I managed to get Baxter's suggestion to work. I wanted to perform a search against a category and a date range I had make sure that these things were correct:

  1. create a java.util.Vector (keys).
  2. keys.addElement(Category)
  3. keys.addElement(daterange)
  4. getAllDocumentsByKey(keys, true).GetCount()
  5. the view had to be modified that category is the first sorted column and the date column is the second and sorted.

Then it worked like a charm. It is much faster than using  NotesViewNavigator

I did not try full text search, I am happy with the getAllDocumentsByKey, but thanks for the suggestion.

 


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal