Checking for a specific field value in parent, response, RtoR documents

I have written an agent that collects all the responses and response-to-response for a given parent document.

What I want to do next is go through all these documents including the parent and check for value in the fieldA ( this exists on all documents including parent).

If fieldA = “” on ALL documents, then change the value of another fieldB on all documents to “” ( If even one of the documents has FieldA equals to something, then do nothing). I have tried DO until Loops but is not working correctly.

The part I am having difficulty is checking if fieldA = “” on ALL documents. Any ideas would be appreciated.

Thank you

Archana

Subject: Checking for a specific field value in parent, response, RtoR documents

I would awrite a function to return a boolean value

function FieldABlank(doc as NotesDocument) as boolean

if doc.hasitem(“FieldA”) then //Ensure that item exists in doc

FieldABlank = (doc.fieldA(0) = “”)

else

FieldABlank = true

end if

End function

dim FieldAEmpty as boolean

In the document collection [Since u have already done that]

testFieldA = testFieldA or FieldABlank(doc)

end loop

if FieldAEmpty then ’ if TRUE then FieldA was null/empty in all docs

fieldB = New value

Similarly u can write a function to set the FieldB in all docs, remember to save the docs though.

Subject: Checking for a specific field value in parent, response, RtoR documents

Look up the responses function of the NotesDocumentCollection. It does not deal with respose to response but you could write a recursive function for that and get what you want.

HTH

Subject: RE: Checking for a specific field value in parent, response, RtoR documents

Dave,

Thank you for the response. I laready have the responses and RtoR documents. I was just not able to figure out a way to check if that fieldA on all documents was blank or not.

Anyway, after some intense nail biting:) I figured it out. Hopefully, it works correctly.

Archana

Subject: RE: Checking for a specific field value in parent, response, RtoR documents

Did you consider to use a FT search or search at least for pre-filtering your results? FT search performs better, but you cannot make sure, that a field contains a value exactly, so you might still have to loop through the results to check for the exact right value. Still, this could be faster than any other way to get responses and all levels of response-to-response documents.

The beauty of having all your documents in one collection is, that you can set the one new field value very efficiently using the collection’s StampAll method.