cancel
Showing results for 
Search instead for 
Did you mean: 

Example of Creating a Note via the Unity API

Ed_Cannon
Champ on-the-rise
Champ on-the-rise

Does anyone have a good example of how to use the NoteModifier Method to create a note on a document? I have been unable to find any information or examples on this in the API documentation.  Thanks.. 

4 REPLIES 4

Timothy_Cosgrif
Star Collaborator
Star Collaborator

You can find the information about the NoteModifier class in the SDK under Unity API > Reference > Hyland.Unity Namespace > NoteModifier Class. This class is used to create a NoteProperties object that will actually create the Note, and then the NoteModifier will add the Note to the Document.

The following is a very basic method of creating a note on a document in C# (although easily translatable to VB.Net). All of the classes used a fully documented in the Reference section of the Unity API in the SDK.

Document doc = app.Core.GetDocumentByID(101);
NoteType noteType = app.Core.NoteTypes.Find("Yellow Note");
NoteModifier noteMod = doc.CreateNoteModifier();
// Create the NoteProperties
NoteProperties noteProps = noteMod.CreateNoteProperties();
noteProps.Text = "New note text";
noteProps.PageNumber = 2;
// Create the Note
Note newNote = noteType.CreateNote(noteProps);
noteMod.AddNote(newNote);
noteMod.ApplyChanges(); // Must apply changes.

Thanks Tim... This was what I was looking for.

Ed_Cannon
Champ on-the-rise
Champ on-the-rise

I am having trouble updating/removing an existing note on a document. The document.note.find doesn't seem to work the way I think it should.

Thanks

Timothy_Cosgrif
Star Collaborator
Star Collaborator

The Find method off of NoteList has 3 overloads. First, a long for the Note ID. Next, a string of the Auto-Name string of the Note. Third, a Predicate(T) where T is a Note object and the predicate returns bool.

So, to find a Note based on the NoteType ID, the third overload is needed. Using a lambda expression, it would look like: document.Notes.Find( (note) => {return note.NoteType.ID == noteTypeID});

This, of course, would only return 1 note, even if there are multiple notes . The FindAll method works the same as the predicate example, but will return a NoteList.