1
votes

I have the following code which I have in the Bind data part of a repeat control. I have called the Collection Name 'docs'. I cannot seem to make any values appear in the view control. Computed Field - docs.getItemValue("Status"). Any ideas where I'm going wrong?

var v:NotesView = database.getView("xpageReports");
viewScope.status=""

// Created After
var after = viewScope.crafter
if(after==null)after = @Date(2000, 1, 1, 0, 0, 0);  

// Created Before
var before = viewScope.crbefore 
if(before==null) before = @Date( @Tomorrow() );

// Build Date Range
var dr = session.createDateRange(after, before);

// Status
var status = viewScope.crstatus;
if(status =="-select-") status =""
// Department
var department = viewScope.crdepartment;
if(department =="-select-") department=""

// Unit
var unit = viewScope.crunit;
if(unit ="-select-") unit=""

var dc:NotesDocumentCollection = v.getAllDocumentsByKey(dr);
if (dc.getCount() == 0) {
    viewScope.status = "0";
    return;
}

var count = 0
var doc:NotesDocument = dc.getFirstDocument();
while (doc != null) {
    var tmpdoc = dc.getNextDocument();
    var remove = 0

    @If(status!="",@If(doc.getItemValueString("Status")!=status,remove = remove + 1,""),"")
    @If(department!="",@If(doc.getItemValueString("Department")!=department,remove = remove + 1,""),"")
    @If(unit!="",@If(doc.getItemValueString("Unit")!=unit,remove = remove + 1,""),"")
    if(remove!=0) dc.deleteDocument(doc)

    doc.recycle();


    doc = tmpdoc;

    }

return dc
2
what exactly is your problem with repeat? - Frantisek Kossuth
I think you need to make sure the looked up value type is the same as the value you have in the first column in the view. I have neer tried to lookup values using dates.I would troubleshoot this by converting both the lookup value and the view value to text and see if that works first. - Thomas Adrian
I dont know, it wont display any values. The lookup works fine, I can make it print out a count of the documents found, but I cant seem to make any document values appear in the repeat control - brtweed
Where exactly do you use the script you posted above? What is the data source of the xpage and/or repeat? - Michael Ruhnau
I changed the data binding of the repeat control to Javascript and added this. The data source of the page is the original form - brtweed

2 Answers

1
votes

I changed the code to return the noteIDs of the documents and placed this inside the Bind Data section of the repeat control, and set the Collection Name to docs

var v:NotesView = database.getView("xpageReports");
var docIDs = ""

// Created After
var after = viewScope.crafter
if(after==null)after = @Date(2000, 1, 1, 0, 0, 0);  

// Created Before
var before = viewScope.crbefore 
if(before==null) before = @Date( @Tomorrow() );

// Build Date Range
var dr = session.createDateRange(after, before);

// Status
var status = viewScope.crstatus;
if(status =="-select-") status =""
// Department
var department = viewScope.crdepartment;
if(department =="-select-") department=""

// Unit
var unit = viewScope.crunit;
if(unit =="-select-") unit=""

var dc:NotesDocumentCollection = v.getAllDocumentsByKey(dr);
if (dc.getCount() == 0) {
    return;
}

var count = 0
var doc:NotesDocument = dc.getFirstDocument();
while (doc != null) {
    var tmpdoc = dc.getNextDocument();
    var remove = 0

    @If(status!="",@If(doc.getItemValueString("Status")!=status,remove = remove + 1,""),"")
    @If(department!="",@If(doc.getItemValueString("Department")!=department,remove = remove + 1,""),"")
    @If(unit!="",@If(doc.getItemValueString("Unit")!=unit,remove = remove + 1,""),"")
    if(remove==0) docIDs = docIDs = docIDs + doc.getNoteID()+";"

    doc.recycle();
    doc = tmpdoc;

}
return @Explode(docIDs,";")

Then I placed a panel inside the repeat control, set the data source to the form of the documents and set the Document ID field to computed and entered docs. Now any computed fields I put inside the panel can be bound to the form field

0
votes

As far as I understand your question you want to display subset of documents in a view in the repeat control - your filtering should be done by date range. I accomplished something similar by using the following logic:

  1. The data source of my custom control / xpage was a view (in your case the view "xpageReports") with data source name = "view1".
  2. In the data source properties you have three options to narrow down your document set: "filter by category name", "filter by column value" and "search in view results". In my case I used "search in view results" (in a database with fulltext index). So you can use a JavaScript to create a query like this:

'[dateAfter]>=01.01.2000 AND [dateAfter]<=31.12.2012';

  1. In the repeat you can set the source to "view1"

  2. collection name can be set to "mydoc"

  3. A column value in a computed field within the repeat can be accessed by using the code

mydoc.getColumnValue("PROGRAMMATICCOLUMNNAME");

I hope that is a hint into the right direction. As far as I understand that should fit your requirements.