Forall and documentcollection

Forall and documentcollection

Post by tbuitel.. » Wed, 22 Dec 1999 04:00:00



I have a problem with a script i wrote. I have to set some field on the

...
    Dim dc As notesdocumentcollection
    Set dc = db.unprocesseddocuments
...
    Select Case code
     Case "2":
          Forall d In dc
          'setting multiple fields here and saving the document
          End Forall
     Case "5":
          Forall d in dc....
...

But notes won't let me save this script because is has a script error.
In the line "forall d in dc" it says dc is not an array,list,
collection or variant....!?
I can workaround this by using functions like getnextdocument, but
using "forall" would make the script much easier...
Does anyone know why notes generates this error ??? and how i can make
this script work..???

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

Forall and documentcollection

Post by Herbert van Vlie » Wed, 22 Dec 1999 04:00:00


with a document collection, use the
    set myDoc = myColl.getFirstDocument
and
    set myDoc = myColl.getNextDocument( myDoc )
to loop through, while myDoc is not nothing.
Remember that <myDoc> might be removed from the collection somehow, in which
case you can't get the next document anymore, so do a:
    set myDoc = myColl.getFirstDocument
    while not myDoc is nothing
        set myNext = myColl.getNextDocument( myDoc )
        'do stuff with <myDoc>
        set myDoc = myNext
    wend
/Herbert


>I have a problem with a script i wrote. I have to set some field on the

>...
>    Dim dc As notesdocumentcollection
>    Set dc = db.unprocesseddocuments
>...
>    Select Case code
>     Case "2":
>          Forall d In dc
>          'setting multiple fields here and saving the document
>          End Forall
>     Case "5":
>          Forall d in dc....
>...

>But notes won't let me save this script because is has a script error.
>In the line "forall d in dc" it says dc is not an array,list,
>collection or variant....!?
>I can workaround this by using functions like getnextdocument, but
>using "forall" would make the script much easier...
>Does anyone know why notes generates this error ??? and how i can make
>this script work..???

>Sent via Deja.com http://www.deja.com/
>Before you buy.