CopyAllItems causing problem with permissions

Hi,
It's been a while since I posted in here but I have an odd problem that I'm hoping someone can help me with.
I have a function in a script library which creates a new copy of my existing document. The document is a person record in an HR system and in the event that their position changes I want to create an archive copy of their old HR document.

Although the code works the new document can't be read or even seen by me. I can see it if I run Notes on the server and access the database that way. I do have Readers and Authors fields on the original document (Employee) and the archived copy (Employee Position). These fields still exist on the EP document and look to be correct but in fact their type has changed from Text List to Text.

Why does this happen ? What's the best way to copy a multivalue Authors field from one document to another ?

Code to do the copy is here:
Public Function CreateEPR As Integer
      
      Dim workspace As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Dim doc As NotesDocument
      Dim currentdoc As NotesDocument
      Dim db As NotesDatabase
      Dim session As New NotesSession
      
      Set db = session.CurrentDatabase
      Set doc = New NotesDocument(db)
      Set uidoc = workspace.CurrentDocument
      Set currentdoc = uidoc.Document
      
      currentdoc.CopyAllItems doc, False
      doc.Form="Employee Position"
      
      Call doc.Save (True,True)
      
End Function

The new copy of the documentOriginal-doc.PNG
andyhinesAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sjef BosmanGroupware ConsultantCommented:
And, er... this one:

Public Function CreateEPR As Integer
      
      Dim workspace As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Dim doc As NotesDocument
      Dim currentdoc As NotesDocument
      Dim db As NotesDatabase
      Dim session As New NotesSession
      
      Set db = session.CurrentDatabase
'      Set doc = New NotesDocument(db)
      Set uidoc = workspace.CurrentDocument
      Set currentdoc = uidoc.Document
      
      Set doc= currentDoc.CopyToDatabase(db)
      doc.Form="Employee Position"
      
      Call doc.Save (True,True)
      
End Function

Open in new window

Of course, that would only work for someone who has at least Author rights on the document.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
andyhinesAuthor Commented:
Thank you sjef - you're a star.
That works perfectly.
Is this a known problem or wasI just trying to use it wrongly.

Regards - Andy
Sjef BosmanGroupware ConsultantCommented:
AFAIK you did nothing wrong. Sometimes Notes does just a bit weird... but most of the times it behaves nicely. I still prefer (Notes and) Domino, and XPages these days does a great job. Integration-wise they are still miles ahead of the competition, IMHO. But that's just My HO...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.