Author fields - follow up post

I did post something on author fields a few weeks ago and did get helpful advise unfortunately I let me problem sit. I would like to add an author field to a group of documents. Is there something specific I have to do to make sure the system recognizes the field as an author field and not a text field. I created an author field on the form and then tried to populate it through a simple agent but did doesn’t seem to work.

thanks

Sue

Subject: Author fields - follow up post

Unfortunatley the Simple agent does not set the field type for Authors/Readers etc. You will need to write a Lotus Script agent.

Is this a one off fix and how many documents are we talking about?

Subject: RE: Author fields - follow up post

This would be a one time fix. I tried writing a script and it seemed to work but then I reached a document that I guess doesn’t contain an authors field. I don’t understand why. When I view document properties on the view the field Author field is not there but when I open the document and then view the properties is it there. I have myself totally messed up. I guess my best bet would be to somehow add an authors field to every document and place the value of [Auditor] in the field. I guess my problem started when I download these documents from Access not thinking about the Author field. I have 931 documents that need to be changed.The code I used in my agent was-

Sub Initialize

Dim session As NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument

Dim item As NotesItem



Set session = New NotesSession

Set db = session.CurrentDatabase

Set view = db.GetView("sue testing")

Set doc = view.GetFirstDocument

While Not(doc Is Nothing)

	Set item = doc.GetFirstItem("Author")

	If item.IsAuthors Then

		Call item.AppendToTextList("[Auditor]")

		Call doc.Save(False, True)

	End If

	Set doc = view.GetNextDocument(doc)

	

Wend

End Sub

Is there I way I can add a new item to all of the documents through LotusScript. Something like

Set tmpitem = new notesitem(Finding Report,“F_Author”,“[Auditor]”,AUTHORS) and then resave the doc with this field on it.

thanks

Sue

Subject: RE: Author fields - follow up post

You will need to delete the exiting Authors field and recreate it as an authors field. Try this:

Sub Initialize

Dim session As NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument

Dim item As NotesItem



Set session = New NotesSession

Set db = session.CurrentDatabase

Set view = db.GetView("sue testing")

Set doc = view.GetFirstDocument

Dim oldvalues As Variant ' <-- This is needed the hold the old values

While Not(doc Is Nothing)

	Set item = doc.GetFirstItem("Author")

	If Not (item Is Nothing) Then

		oldvalues = item.Values '<-- store the old values			

		Call item.Remove ' <-- need to removed the exiting item

	End If

	Dim newitem As New NotesItem(Doc, "Author" , oldvalues , AUTHORS) ' <-- now recreate the item as an authors field

	Call newitem.AppendToTextList("[Auditor]")		

	Call doc.Save(False, True)

	

	Set doc = view.GetNextDocument(doc)

	

Wend

End Sub

Subject: No need to be so complicated…

While Not(doc Is Nothing)		Set item = doc.GetFirstItem("Author")

	Call item.AppendToTextList("[Auditor]")

	item.IsAuthors = True

	Call doc.Save(False, True)

Subject: true

Subject: RE: Author fields - follow up post

thanks so much for your help. I was able to make the changes I needed.