NoteClient Methods
The NoteClient object contains the following methods:
AddTypeDefinition
The AddTypeDefinition method attempts to add a note type, or will error if one already exists.
Syntax
AddTypeDefinition(Type As String)
Parameters
| Parameter | Description |
|---|---|
|
Type |
The note type definition. Note: The following conditions will produce an error: if first character is a space, if the string is empty, if the string is greater than 20 characters, if the string contains anything that isn’t a number, letter, space, dash or underscore. |
Example
The following example adds a note type of "PROD NOTE" to the MYSITE.NOTE service.
Dim CxNote
Set CxNote = CreateObject("CxNote.NoteClient")
CxNote.Connect "MYSITE.NOTE"
CxNote.AddTypeDefinition "PROD NOTE"
Connect
The Connect method connects the object to a service.
Syntax
Connect(DomainSiteService As String)
Parameters
| Parameter | Required | Description |
|---|---|---|
|
DomainSiteService |
Yes |
The [Domain]Site.Service to which to connect. The domain is optional. The service must be a valid one. |
Remarks
Returns 0 if successful and a non-zero value if the connection failed.
Example
The following example connects the Client object to the CYGDEMO.<SVC> on domain 5410:
Connect
Sub NoteConnect()
'Connect to a NOTE
Dim NoteClient
Set NoteClient = CreateObject("CxNote.NoteClient")
NoteClient.Connect("[5410]CYGDEMO.NOTE")
End Sub
CreateNote
The CreateNote method submits a note object to the specified Note Service.
Syntax
CreateNote(Note As Note) As Note
Parameters
| Parameter | Description |
|---|---|
|
Note |
Specifies the note object being submitted to the specified Note Service. |
Return Values
This method returns the new note object as it was fully initialized by the Note Service.
Example
The following example illustrates the CreateNote method in an applied situation. The script in this example connects to Note Service, sets a note object, specifies the properties of the note, returns the new note object as it was fully initialized by the Note Service, and displays confirmation in a message box.
Dim NoteService
Set NoteService = CreateObject("CxNote.NoteClient")
NoteService.Connect "MYSITE.NOTE"
Dim NewNote
Set NewNote = CreateObject("CxNote.Note")
NewNote.StartDateTime = CDate("2023-11-29 2:25")
NewNote.EndDateTime = CDate("2023-11-29 14:25")
NewNote.Summary = "A new note created through CxNote"
NewNote.Type = "Test Note"
NewNote.Body = "Body text for a note, unlimited characters!"
Dim NoteAfterCreation
Set NoteAfterCreation = NoteService.CreateNote(NewNote)
msgbox NoteAfterCreation.NoteTag
msgbox NoteAfterCreation.Summary
msgbox NoteAfterCreation.Body
DeleteNote
The DeleteNote method deletes a note from the specified Note Service.
Syntax
DeleteNote(NoteTag As String)
Parameters
| Parameter | Description |
|---|---|
|
NoteTag |
Specifies the unique tag of a note. It is in the format SITE.SERVICE~NOTENUMBER. The database key (DbKey) for the note with no preceding zeroes makes up NOTENUMBER. |
Return Values
This method has no return value.
DeleteTypeDefinition
The DeleteTypeDefinition method attempts to delete the note type definition, or will error if one doesn’t exist.
Syntax
DeleteTypeDefinition(Type As String)
Parameters
| Parameter | Description |
|---|---|
|
Type |
The note type definition. Note: The following conditions will produce an error: if first character is a space, if the string is empty, if the string is greater than 20 characters, if the string contains anything that isn’t a number, letter, space, dash or underscore. |
Example
The following example deletes a note type of "TEST NOTE" from the MYSITE.NOTE service.
Dim CxNote
Set CxNote = CreateObject("CxNote.NoteClient")
CxNote.Connect "MYSITE.NOTE"
CxNote.DeleteTypeDefinition "TEST NOTE"
Disconnect
The Disconnect method disconnects from the connected service.
Syntax
Disconnect() As Integer
Remarks
The Disconnect method returns 0 if successful and a non-zero value if the disconnect failed.
Example
The following example disconnects the Client object from the connected service, and pops a message box if it is unsuccessful:
Sub Svc.Disconnect()
<SvcClient>.Disconnect()
MsgBox "Service has disconnected."
If <SvcClient>.Disconnect <> 0
Then
MsgBox "Failed to disconnect."
End If
End Sub
GetActiveNoteTypes
The GetActiveNoteTypes method gets all currently active note types used by a Note Service.
Syntax
GetActiveNoteTypes()
Return Values
This method returns all currently active note types used by a Note Service in an array of strings.
Example
The following example illustrates the GetActiveNoteTypes method in an applied situation. The script in this example connects to Note Service, gets the currently active note types, displays the upper bound of the returned array, and displays the string value of the first type in the string array.
Dim CxNote
Set CxNote = CreateObject("CxNote.NoteClient")
CxNote.Connect "MYSITE.NOTE"
Dim TypesList
TypesList = CxNote.GetActiveNoteTypes
msgbox UBound(TypesList)
msgbox TypesList(1)
GetConsoleData
The GetConsoleData method returns the console text and display attributes as two 25x80 arrays of unsigned characters.
Syntax
GetConsoleData(ByRef pText, ByRef pAttr) As Integer
Parameters
| Parameter | Required | Description |
|---|---|---|
|
pText |
Yes |
A two-dimensional 25x80 array of console text attributes returned by this method. |
|
pAttr |
Yes |
A two-dimensional 25x80 array of console display attributes returned by this method. |
Remarks
This method returns 0 if successful.
Example
The following example writes the console text and display attributes to a CSV file.
Sub
Dim aryText, aryAttr, nRet
nRet = <NameofServiceClientObject>.GetConsoleData(aryText, aryAttr)
' Write text attributes to CSV file
Dim i, j, strMsg
For i = 0 To UBound(aryText, 1)
For j = 0 To UBound(aryText, 2)
strMsg = strMsg + CStr(aryText(i, j)) + ","
Next
strMsg = strMsg + vbCr
Next
dim fso, file
Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.OpenTextFile("c:\console_text_attrs.csv", 2, True)
file.WriteLine(strMsg)
file.Close
strMsg = ""
' Write display attributes to CSV file
For i = 0 To UBound(aryAttr, 1)
For j = 0 To UBound(aryAttr, 2)
strMsg = strMsg + CStr(aryAttr(i, j)) + ","
Next
strMsg = strMsg + vbCr
Next
Set file = fso.OpenTextFile("c:\console_disp_attrs.csv", 2, True)
file.WriteLine(strMsg)
file.Close
MsgBox nRet
End Sub
GetNote
The GetNote method gets a note object from a Note Service by the note's note tag.
Syntax
GetNote(NoteTag As String, [GetBody As Boolean], [GetAssociations As Boolean]) As Note
Parameters
| Parameter | Description |
|---|---|
|
NoteTag |
Specifies the unique tag of a note. It is in the format SITE.SERVICE~NOTENUMBER. This parameter is required. |
|
GetBody |
Loads the body text for the specified note. This parameter is optional. The default is True. |
|
GetAssociations |
Loads the associations for the specified note. This parameter is optional. The default is True. |
Return Values
This method returns a note object from a Note Service by the note's note tag.
Example
The following example illustrates the GetNote method in an applied situation. The script in this example connects to Note Service, sets a full note (i.e., with body and associations by default), a minimal note (i.e., with no body and associations), and confirms expected behavior in the message box.
Dim CxNote
Set CxNote = CreateObject("CxNote.NoteClient")
CxNote.Connect "MYSITE.NOTE"
Dim FullyLoadedNote
Set FullyLoadedNote = CxNote.GetNote("MYSITE.NOTE~698")
Dim BareMinimumNote
Set BareMinimumNote = CxNote.GetNote("MYSITE.NOTE~698", false, false)
'this will be true
msgbox FullyLoadedNote.HasBody
'this will be false
msgbox BareMinimumNote.HasBody
GetNotesByAssociations
The GetNotesByAssociations method gets an array of notes that correspond to specified parameters.
Syntax
GetNotesByAssociations(Associations, StartTime As Date, EndTime As Date, NoteType As String, [GetBody As Boolean = True], [GetAssociations As Boolean = True])
Parameters
| Parameter | Description |
|---|---|
|
Associations |
This is an array of associations from which you want notes. |
|
StartTime |
Specifies the starting date and time for a date range. |
|
EndTime |
Specifies the ending date and time for a date range. |
|
NoteType |
Specifies a single note type for all notes to be returned in the specified association and date/time range. If blank, returns all note types. |
|
GetBody |
Loads the body text for the specified note from the Note Service. This parameter is optional. The default is False. |
|
GetAssociations |
Loads the associations for the specified note from the Note Service. This parameter is optional. The default is False. |
Return Values
This method returns the array of notes corresponding to the specified parameters.
Example
The following example illustrates the GetNotesByAssociations method in an applied situation. The script in this example connects to a Note Service, creates an array of associations, retrieves an array of notes corresponding to the array of associations, and defines the begin time and end time for the request. It then displays the size of the array and shows a note tag from that array.
Dim NoteServ
Set NoteServ = CreateObject("CxNote.NoteClient")
NoteServ.Connect "MYSITE.NOTE"
Dim assocFacPnt(2)
Set assocFacPnt(1) = CreateObject("CxNote.Association")
Set assocFacPnt(2) = CreateObject("CxNote.Association")
assocFacPnt(1).SetAssociation"MYSITE.UIS::NOTETEST" ,0
assocFacPnt(2).SetAssociation"MYSITE.UIS::NOTETEST.NOTE_0" ,1
Dim dateStart : dateStart = CDate("0:00 2023-1-1")
Dim dateEnd : dateEnd = CDate("23:59 2023-12-30")
Dim notes
notes = NoteServ.GetNotesByAssociations(assocFacPnt, dateStart, dateEnd, "")
MsgBox UBound(notes)
MsgBox notes(1).NoteTag
GetReferences
The GetReferences method refreshes the list of services referenced by the connected service.
Syntax
GetReferences() As Integer
Return Values
This method returns all references for the connected service.
Example
The following example refreshes the connected services:
Sub GetReferences()
<NameofServiceClientObject>.GetReferences
MsgBox "Services references retrieved"
End Sub
RenameTypeDefinition
The RenameTypeDefinition method deletes the old note type definition and adds the new note type definition. The function will error if the old note type doesn’t exist or if the new note type already exists.
Syntax
RenameTypeDefinition(OldType As String, NewType As String)
Parameters
| Parameter | Description |
|---|---|
|
OldType |
The old note type definition. |
|
NewType |
The new note type definition. Note: The following conditions will produce an error: if first character is a space, if the string is empty, if the string is greater than 20 characters, if the string contains anything that isn’t a number, letter, space, dash or underscore. |
Example
The following example deletes the old note type "PROD NOTE" and adds a new note type named "PRODUCTION" on the MYSITE.NOTE service.
Dim CxNote
Set CxNote = CreateObject("CxNote.NoteClient")
CxNote.Connect "MYSITE.NOTE"
CxNote.RenameTypeDefinition "PROD NOTE", "PRODUCTION"
RetrieveNoteData
The RetrieveNoteData method refreshes the note data for a given note from the Note Service. The note before the call and after the call remains the same.
Syntax
RetrieveNoteData(Note As Note, [GetBody], [GetAssociations], [OverwriteChangedData])
Parameters
| Parameter | Description |
|---|---|
|
Note |
Specifies the note object for which you want to retrieve data. |
|
GetBody |
Loads the body text for the specified note from the Note Service. This parameter is optional. The default is True. |
|
GetAssociations |
Loads the associations for the specified note from the Note Service. This parameter is optional. The default is True. |
|
OverwriteChangedData |
Overwrites client note data with Note Service data. This parameter is optional. The default is True. |
Return Values
This method has no return value.
UpdateNote
The UpdateNote method submits an existing note object back into a Note Service after edits have been made.
Syntax
UpdateNote(Note As Note) As Note
Parameters
| Parameter | Description |
|---|---|
|
Note |
Specifies the note object being submitted to the specified Note Service. |
Return Values
This method returns the note object as it was fully initialized by the Note Service.
Example
The following example illustrates the UpdateNote method in an applied situation.
Dim CxNote
Set CxNote = CreateObject("CxNote.NoteClient")
CxNote.Connect "MYSITE.NOTE"
Dim NoteToEdit
Set NoteToEdit= CxNote.GetNote("MYSITE.NOTE~698")
NoteToEdit.Summary = "Different summary"
Dim OldBody
OldBody = NoteToEdit.Body
NoteToEdit.Body = OldBody & " adding new body text"
CxNote.UpdateNote NoteToEdit
MsgBox NoteToEdit.Body
MsgBox NoteToEdit.Summary


