Copy Readers and Authors Fields & Putting them into a new document

I am in need of more assistance. I am not trying to copy the readers and authors fields from one document to another and it is putting them as text into the new fields on the new document. Can someone help me and enlighten me on how to Get the readers and authors field and then Set those fields on the new document?

Here is the code:

Sub Initialize

Dim session As New NotesSession 

'  Dim CMSdb As New NotesDatabase( "", "cacms.nsf" ) 'db set right here

'  Dim CMSIIdb As New NotesDatabase("", "CMSII.nsf") 'db set here

Dim db As NotesDatabase

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim view As NotesView

Dim j As Integer



Set session = New NotesSession

Set ws = New NotesUIWorkspace

Set db= session.CurrentDatabase

Set view = db.GetView("MainView")

Set collection =db.UnprocessedDocuments



For j = 1 To collection.Count

	Set doc = collection.GetNthDocument(j)

	' get the fields from the CMS document

	Set ActType = doc.GetFirstItem( "ActivityType" )

	Set CName = doc.GetFirstItem("Company")

	Set CoType = doc.GetFirstItem("CompanyType")

	Set ETitle = doc.GetFirstItem("Subject")

	Set DETAILS = doc.GetFirstItem("Details")

	Set TOPIC = doc.GetFirstItem("Events")

	Set Att = doc.GetFirstItem("Attendees")

	Set Ag = doc.GetFirstItem("Agenda")

	Set Objec = doc.GetFirstItem("Objective")

	Set SubTop = doc.GetFirstItem("Location")

	Set D = doc.GetFirstItem("Dates")

	Set STime = doc.GetFirstItem("Time1")

	Set ETime = doc.GetFirstItem("Time2")

	Set Dur = doc.GetFirstItem("Duration")

	Set WBeg = doc.GetFirstItem("WeekBeginning")

	' Set Com = doc.GetFirstItem("Comment")

	Set iRep = doc.GetFirstItem("IRep")

	Set rep = doc.GetFirstItem("Rep")

********** These two statements are where it is getting the readers and authors fields from the document ***********

	Set Reader = doc.GetFirstItem("DocReaders")

	Set Author = doc.GetFirstItem("DocAuthors")

	

	'Compose the CMS II document --- have to define the exact form that you want

	Set uidoc = ws.ComposeDocument _

	( "Domino/Cardinal", "CMS\CMS2.nsf", "Activity" )

	

	' Set the data on the CMSII document

	Call uidoc.FieldSetText("CoName", CName.Text)

	Call uidoc.FieldSetText("CType", CoType.Text)

	Call uidoc.FieldSetText("AType", ActType.Text)

	Call uidoc.FieldSetText("DisplayInfo", CType + " for " + CoName)

	Call uidoc.FieldSetText("DisplayInfo1", "Customer Management System II--- Activity")

	Call uidoc.RefreshHideFormulas		

	Call uidoc.Refresh

	Call uidoc.FieldSetText("EventTitle", ETitle.Text)

	Call uidoc.FieldSetText("Details", DETAILS.Text)

	Call uidoc.FieldSetText("Topic", TOPIC.Text)

	Call uidoc.FieldSetText("Attendees", Att.Text)

	Call uidoc.FieldSetText("Agenda", Ag.Text)

	Call uidoc.FieldSetText("Objective", Objec.Text)

	Call uidoc.FieldSetText("SubTopic", SubTop.Text)

	Call uidoc.FieldSetText("Date", D.Text)

	Call uidoc.FieldSetText("StartTime", STime.Text)

	Call uidoc.FieldSetText("EndTime", ETime.Text)

	Call uidoc.FieldSetText("Duration", Dur.Text)

	Call uidoc.FieldSetText("WeekBeginning", WBeg.Text)

	' Call uidoc.FieldSetText("Comment", Com.Text)

	Call uidoc.FieldSetText("IRep", iRep.Text)

	Call uidoc.FieldSetText("Rep", rep.Text)

************* This is where it is pasting the data as text and not formatting it as a readers field **********

	Call uidoc.FieldSetText("DocReaders", Reader.Text + "Jamie Augustus/Cardinal")

************* This is where it is pasting the data as text and not formatting it as a authors field **********

	Call uidoc.Fieldsettext("DocAuthors", Author.Text + "Jamie Augustus/Cardinal")

	

	' do things to the doc the refresh, save, and close the doc		

	Call uidoc.Refresh

	Call uidoc.RefreshHideFormulas

	Call uidoc.Save

	Call uidoc.Close(True)

Next j

End Sub

Again, need help to “paste” the data in the fields as the readers and authors data so that the secturity may be set.

Thanks and any help is appericated!!!

Subject: Copy Readers and Authors Fields & Putting them into a new document

If you are going through the UI (FieldSetText) and the fields are defined as Readers and Authors types (as appropriate), then it should happen automatically. Make sure, though, that the text you paste into multivalue fields uses a legal multivalue separator for the field (set on the “beanie” tab of the field properties).

Subject: RE: Copy Readers and Authors Fields & Putting them into a new document

Thanks for your response. I changed the mutli-value sep. to the correct value of “;” and it worked. Thanks!!!

Subject: RE: Copy Readers and Authors Fields & Putting them into a new document

Hi Stan… ! Didn’t know you were on and assisting. Hope I didn’t trounch on your suggestion.

Subject: Copy Readers and Authors Fields & Putting them into a new document

Jamie,

I thought I remembered seeing your post earlier. At any rate, the problem(s) you’re having is using the front end to create those documents.

In order to instantiate the authors/readers fields, it’s a bit better to do it in the back end.

I’ve revised your code a bit so it runs on the back end, and also does a bit more efficient stepping through the collection.

See if this makes sense to you:

Dim session As New NotesSession

Dim db As NotesDatabase

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument	

Dim view As NotesView

Dim j As Integer



Set session = New NotesSession

Set db= session.CurrentDatabase

Set view = db.GetView("MainView")

Set collection =db.UnprocessedDocuments

Dim newDoc As NotesDocument



If collection.Count <1 Then Exit Sub

Dim count As Long

Dim item_Readers As NotesItem

Dim item_Authors As NotesItem

Dim readers As Variant

Dim authors As Variant

'if the new documents are in a second database then you need to instantiate that database

Dim CMSIIdb As New NotesDatabase( "Domino/Cardinal", "CMS\CMS2.nsf")

If Not CMSIIdb.IsOpen Then

	Call CMSIIdb.Open("","")		

End If

If Not CMSIIdb.IsOpen Then

	Msgbox "Sorry, couldn't open the CMS2 Database",,"Unable to Continue"

	Exit Sub

End If



Set doc = collection.getFirstDocument

While Not doc Is Nothing

	readers = doc.GetItemValue("DocReaders")

	authors = doc.GetItemValue("DocAuthors")

	

	Set newDoc = New NotesDocument(CMSIIdb)

	With newdoc

		.form = "Activity"

		.ActivityType = doc.GetFirstItem( "ActivityType" )

		.Company = doc.GetFirstItem("Company")

		.CompanyType = doc.GetFirstItem("CompanyType")

		.Subject= doc.GetFirstItem("Subject")

		.Details = doc.GetFirstItem("Details")

		.Events = doc.GetFirstItem("Events")

		.Attendees= doc.GetFirstItem("Attendees")

		.Agenda = doc.GetFirstItem("Agenda")

		.Objective = doc.GetFirstItem("Objective")

		.Location = doc.GetFirstItem("Location")

		.Dates = doc.GetFirstItem("Dates")

		.Time1 = doc.GetFirstItem("Time1")

		.Time2 = doc.GetFirstItem("Time2")

		.Duration = doc.GetFirstItem("Duration")

		.WeekBeginning = doc.GetFirstItem("WeekBeginning")

           ' .Comment = doc.GetFirstItem("Comment")

		.iRep = doc.GetFirstItem("IRep")

		.Rep = doc.GetFirstItem("Rep")

		Set item_Readers = New NotesItem(newdoc,"DocReaders",readers,READERS)

		Set item_AUTHORS= New NotesItem(newDoc,"DocAuthors",authors,AUTHORS)

		.computewithform False, False

		.save True, False, True

	End With

	count = count +1

	Set doc = collection.getNextDocument(doc)		

Wend



Msgbox "Finished processing " + Cstr(count) + " Documents."

End Sub

Good Luck,

Marilyn

Subject: RE: Copy Readers and Authors Fields & Putting them into a new document

Thank you!! I got it working through Stan’s suggestion. But, I will keep your your in mind for future programming. I have already written several of these scripts in the other manner. But, Thank you very much.

Subject: RE: Copy Readers and Authors Fields & Putting them into a new document

The important thing is that your problem is resolved!

I was curious why you were opening each document in the ui, though.