Rename User Name

Hi,

Is it possible that do an agent to change all fields’s value in all documents in more than one nsf with condition that the field’s value = “A” ??

I want to do this because of one of my user required to change his username.

Anyone can help me?

Thanks

Subject: Rename User Name

Teh,

Yes it can be , assume you have three dbs; A,B,C

here is your pseudo code ( don’t past and run code blindly. Check again since i just wrote the logic )

Dim arrDb(2) as string

arrDb=“A”

arrDb=“B”

arrDb=“C”

For i=0 to ubound(arrDb)

set db= session.getdatabase(server,i)

set coll= db.alldocuments

set doc=coll.getfirstdocument

While not doc is nothing

if ( doc.getitemvalue(“fldnam”)=“something” ) then

do something here

end if

set doc= coll.getnextdocument(doc)

wend

next i

Rishi

Subject: RE: Rename User Name

Thanks Rishi,Instead of using “doc.getitemvalue(“fldnam”)”, I wonder can I check all data in documents, if found have data = “A”, so i change it into “B”?

Subject: RE: Rename User Name

That’s a bit more complex, but probably doable.

Open doc

Loop through all items on the doc (ie you can loop through all fields on the doc without knowing in advance the field names)

For each item, loop through all items in the array (you have to handle multi-value fields).

Samples of this kind of code are in help.

Subject: RE: Rename User Name

Teh,

Your data will be in some notes field , right ? You need to check that field , if that field contains “A” you need to modify that document.

Rishi