09-24-2013 06:00 AM
Getting the notes for the current contact works using this code...
Me.HostFramework.Notes.GetNotes(Nothing, Me.HostApplication.ApplicationState.CurrentContact)
All the three other methods are not working using the same method. They all incorreclt return nothing.
// GROUP
Me.HostFramework.Notes.GetNotes(Nothing, Me.HostApplication.ApplicationState.CurrentGroup, ComponentModel.AggregationType.All, Nothing, True)
// COMPANY
Me.HostFramework.Notes.GetNotes(Nothing, Me.HostApplication.ApplicationState.CurrentCompany, ComponentModel.AggregationType.All, Nothing, True)
// OPPORTUNITY
Me.HostFramework.Notes.GetNotes(Nothing, Me.HostApplication.ApplicationState.CurrentOpportunity, Nothing, True)
Is this a known issues? Is there a ticket number I can track?
Thanks
-- Jim Durkin
09-24-2013 06:49 AM
Jim,
I've never been able to get it to work when I use "nothing" for a filter criteria. When I create a filter criteria and assign it the value "nothing" and use it then it works. I haven't ever tried to figure out what the difference is but you might give that a try.
Stan
09-24-2013 10:05 AM - edited 09-24-2013 10:08 AM
Finally got it to work. Here is the code for anybody else.
'-----------------------------------------------------
' Get the Created_Date field descriptor
'-----------------------------------------------------
Dim CreatedFieldDescriptor As Act.Framework.Notes.NoteFieldDescriptor = Me.HostFramework.Notes.GetFieldDescriptor(Act.Framework.Notes.NoteField.CreateDate)
'-----------------------------------------------------
' Create a Filter Criteria
'-----------------------------------------------------
Dim AllCriteriasArray As IFilterCriteria() = New IFilterCriteria(0) {}
AllCriteriasArray(0) = New FilterClause(New IFilterCriteria() {New DateFilterCriteria(CreatedFieldDescriptor, HostFramework.Activities.MIN_SMALL_DATE_TIME, HostFramework.Activities.MAX_SMALL_DATE_TIME)})
'-----------------------------------------------------
' Create a Soert Criteria
'-----------------------------------------------------
Dim mySortCriteria(0) As Act.Framework.Notes.NoteSortCriteria
mySortCriteria(0) = New Act.Framework.Notes.NoteSortCriteria(CreatedFieldDescriptor, 0)
'-----------------------------------------------------
' Get the count of all the notes attached to the current company
'-----------------------------------------------------
Dim count As Integer = Me.HostFramework.Notes.GetNotes(mySortCriteria, Me.HostApplication.ApplicationState.CurrentCompany, ComponentModel.AggregationType.All, AllCriteriasArray, False).Count
Thanks for the hint Stan. Bad Mojo in my brain today.
-- Jim Durkin
09-24-2013 10:30 AM - edited 09-24-2013 10:31 AM
Stan,
IT DOES WORK with the sort and filter criteria set to nothing.
If you notice in my "Works" code I changed the deferInitalLoad from TRUE to FALSE.
In fact the original code I posted all works if I change the deferInitalLoad parameter to FALSE.
Here is the simplified way to get the notes without building criteria.
// GROUP
Me.HostFramework.Notes.GetNotes(Nothing, Me.HostApplication.ApplicationState.CurrentGroup, ComponentModel.AggregationType.All, Nothing, FALSE)
// COMPANY
Me.HostFramework.Notes.GetNotes(Nothing, Me.HostApplication.ApplicationState.CurrentCompany, ComponentModel.AggregationType.All, Nothing, FALSE)
// OPPORTUNITY
Me.HostFramework.Notes.GetNotes(Nothing, Me.HostApplication.ApplicationState.CurrentOpportunity, Nothing, FALSE)
I will leave the above code available if somebody needs to build filter and sort criterias.
Hope this helps others.
-- Jim Durkin
09-24-2013 01:34 PM
Jim,
Sorry. I've been tied up all day. I noticed that you had DeferInitialLoad set to True and I usually set it to False. That's probaby because it didn't work if you set it to True. I probably changed the filter and the defer at the same time so I thought that using "nothing" for the filter didn't work but creating a filter and setting it to nothing did work. I appreciate the update. It did bother me every time I did it since I didn't think it should matter. Sounds like Swiftpage should check out the code path when you select True for defer initial load.
Stan