Comparing & then Changing Names in Reader Fields

I recently posted a question with regard to Reader fields and now have a bit more information. I am looking for suggestions on how to accomplish the following. I have a database with 16,000+ documents. Their is a reader field with multiple names in the field. We recently had an huge organizational change and the hierarichal structure (names) changed quite a bit. There are 200+ names that have changed and I need to run through all the documents and compare names and where the name appears I need to change it to something else. i.e., John Smith/IS/Chicago/ABC, Mary Johnson/Marketing/Minneapolis/ABC to

John Smith/IS/Minneapolis/ABC, Mary Johnson/Marketing/Chicago/ABC. Any ideas? Thank you in advance.

Subject: Comparing & then Changing Names in Reader Fields

I’m no admin, and I know I mentioned this in your other thread, but is there a reason as to why you’re not using Adminp to do this? We can suggest script and the like to accomplish this sort of task, but it’s a devil of a job in terms of run times etc.

Subject: Use Adminp for One of Its Designed Functions

Cindy,

Ben is right on. Use Adminp and “Leave the Driving to Lotus.”

Just make sure that your database has an appropriate Admin Server designated along with the Update Reader fields function selected.

Bob

Subject: RE: Use Adminp for One of Its Designed Functions

Question: Once the names have been changed can you go back and run AdminP just to change the reader and the author fields without changing the name again?

Subject: RE: Use Adminp for One of Its Designed Functions

Cindy,

Look in your Admin4.nsf for the Adminp request to “Rename in Reader/Author fields.” If its there then you can check the box that says “Perform Request Again.”

HTH,

Bob

Subject: Comparing & then Changing Names in Reader Fields

Are there any chances when there are same user names but in different OU’sie.

John Smith/IS/Chicago/ABC

John Smith/CC/Chicago/ABC

then probably we can write some script which will do a lookup on the names.nsf using the Common Name in readers field and fetch the new values.

Here is a psuedocode :

1)get the document collection

2)loop through the collection and process each document

3)loop through all the values in the readers field. while doing so, using notesname class, convert each name to common name and do a lookup in the names.nsf. Fetch the Abbreviated name from the doc that is returned and assign that to a temporary array.After all the items in the readers field have been covered, replace the readers field value with the values in the array.

Doing this, would keep the values that are unchanged as intact and at the same time for those values that have been changed, will get the new names.

hope this helps

Subject: Comparing & then Changing Names in Reader Fields

Try this.

Dim session As New NotesSession

Dim db As NotesDatabase

Dim dc As NotesDocumentCollection

Dim doc As NotesDocument

Dim y As String

Dim j As Integer



Set db = session.CurrentDatabase

y = "Nametoadd"



Set dc = db.AllDocuments

For j = 1 To dc.Count

	Set doc = dc.GetNthDocument(j)

	Call doc.ReplaceItemValue ("READERSFIELDNAME", y)

			Call doc.Save(True, False)

Next

Subject: RE: Comparing & then Changing Names in Reader Fields

I think Cindy needs something more sophisticated, as she needs to “find and replace” rather than simply over-write. There are a few different ways of going about this, for example something along the lines of this pseudo-code:

r = name we're looking for

For all n in names field

    if n = r then

    replace n's index in the field with r

...

Not supremely efficient, but there it is. You might also want to look at @Replace and the like.

Subject: RE: Comparing & then Changing Names in Reader Fields

Thanks Michael – won’t that replace all the items in the list. There may be 5 names in the reader field and only 2 need to be changed and the rest need to stay the same.

Subject: RE: Comparing & then Changing Names in Reader Fields

Okay…

then ADD an If…Then statement, i.e.,

If x = “NametoREMOVE” Then

		Call doc.ReplaceItemValue ("READERFIELD", "NAMEtoADD")

	End If