cancel
Showing results for 
Search instead for 
Did you mean: 

Unity API (V12) - Copy Note from One Document to Another?

John_Anderson4
Star Collaborator
Star Collaborator

I'm trying to copy a note from one document to another in the Unity API. I'm trying this:

(obviously docList is generated from a query that returns the document to copy from)

Dim noteMod as NoteModifier = args.Document.CreateNoteModifier
            
For Each relDoc as Document in docList
        For Each relDocNote as Note in relDoc.Notes
                    noteMod.AddNote(relDocNote)
         Next
Next

noteMod.ApplyChanges()

It throws an error: "Unexpected error: An error occurred within the Unity API: The note# 3413007 was not found on the document# 23079187"

Is this a supported operation? I could create a new note with all the same attributes I guess, but that's quite a bit more tedious.

Thanks!

3 REPLIES 3

Rich_Roth
Confirmed Champ
Confirmed Champ

John,

I am changing the Note type on a Document as opposed to copying it from one doc to another. To do that, I have to delete the original note and add the new one after retrieving all of the Note attributes. That works, but it did require a little more effort. This works in a V12 environment. I can send you the code if that helps.

Rich

Trying to do the same in V17. I can create the note, but having trouble setting properties like position etc.

Not applicable

Hi John -

The note object you are trying to add to the new document is the exact note from the original document, ID and all. That is not supported in the API. When adding the note, you must use the API to create a brand new note to add to the related document.

...

            NoteModifier noteModifier = relatedDocument.CreateNoteModifier();             foreach (Note note in document.Notes)            {                Note newNote = note.NoteType.CreateNote(note.Text);                noteModifier.AddNote(newNote);                noteModifier.ApplyChanges();            }

...

Thank you,

Alicia