Display Only Documents with Responses in a View

How can I write a selection formula that will display only documents in the db that have response docs?
Who is Participating?
Bozzie4Connect With a Mentor Commented:
If you don't want to touch the documents (by adding a field, like maddy suggests ,  which is a perfectly valid solution), you can also create an agent that puts documents with responses in a folder.
To limit the number of documents it works on, you can use the Document Seleciton in the agent

dim db as notesdatabase
dim s as new notessession
dim coll as notesdocumentcollection
set db = s.currentdatabase
Set coll  = db.AllDocuments
do while not doc is nothing
set resp = doc.responses
if resp is nothing then
' skip
Call doc.RemoveFromFolder( "Documents with responses" )
Call doc.putinfolder("Documents with responses", true )
end if

set doc = coll.getnextdocument()
SELECT Form="Formname" & @AllChildren
mcjannAuthor Commented:
I want to see only "FormName" that have a response not all "FormName"
Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

I did not understood what u mean? U want to display only those form docs which have response. RIGHT?

This should work:

SELECT Form="YourFormNAme" | @AllChildren
mcjannAuthor Commented:
The database contains 100 documents based on "Form" and 15 of these documents have a response. This formula selects 115 documents when I only want 30 (15 "Forms" each with a single response).
USe this:

SELECT Form="Formname" & @DocChildren > 1
mcjannAuthor Commented:
Now I get no documents in the view.
Even when I try @DocChildren=1 or >0
@DocChildren won't work in selection formula.

ur requirement cannnot be achieved.

what u need to do is,
if there is any response document created, update a field in parent and response document as "yes" and make this selection formula in view;
Select form="urformname" & fieldname="yes" | @Allchildren

Since u have already created docs,u need to write some script to update parent and child docs according to above logic and display the result.

Note that there is no striaght forward solution for you.
mcjannAuthor Commented:

I set the same field on both forms.
The response doc inherets values from the main document.
Field exchange on the main form is not disabled.

I update the field  on the querysave (?) of the response doc.
The field on the response doc updated but the main form did not
Is this becasue the document is not in edit?
The main document should not be edited perhaps a computed field?
Both parent and child documents should have same value.

I mean for all the documents(response and child) should have one data(field) in common and that field should hold a key. we can utilize that field as the key for our view selection formula.

Hoe it helps.

I am leaving office. Will respond tomorrow
Can't do it with a view.  Bozzie's solution will work, though you have to run it regularly, and it will be inefficent when run that way (of course, if you only have a few hundred docs at most, that shluld be OK).

You should also create the folder DOCUMENTS WITH RESPONSES in advance, so you can set the design of it.  Otherwise, the PutInFolder command will create it on the fly, using the default folder design as a guide.

If you want to avoid that, flag the parent documents, but the code is going to be more or less the same.  Instead of doc.putInFolder and doc.removeFromFolder, you would use
        doc.flagAsHavingRespnses = 1
        doc.flagAsHavingRespnses = 0

Then just base you view on flagAsHavingRespnses

In iether case, there will be some lag time between adding a response to a responseless document, or removing all responses from a document, and the time the doc appears in/disappears from the folder or view.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.