Community
Showing results for 
Search instead for 
Do you mean 
Reply

Bug in GetActivitiesForCompany

Bronze Super Contributor
Posts: 1,231
Country: USA

Bug in GetActivitiesForCompany

[ Edited ]

Found a bug in GetActivitiesForCompany() method.

Probable wil also find it in GetActivitiesForGroups and GetActivitiesForOpportunities.

 

If you add a filter to the GetActivitiesForContact() function is works ok.

'-----------------------------------------------------------------

' Add a filter for only uncleared activities

'-----------------------------------------------------------------

Dim aCleared As ActivityComparisonFilterCriteria = New ActivityComparisonFilterCriteria(New ActivityFieldDescriptor(ActivityField.IsCleared), ActivityComparisonFilterCriteria.Operation.Equals, 0)

                                            FilterArray.Add(aCleared)

                                            FilterArray.CopyTo(aFilter)

count = Me.HostFramework.Activities.GetActivitiesForContact(Nothing, aFilter, Me.HostApplication.ApplicationState.CurrentContact, FirstInstanceRestriction.FirstUnclearedOccurrence).Count

 

 

 

 If you add a filter to the GetActivitiesForCompany() function it throws a System.NullReferenceException Exception error.

'-----------------------------------------------------------------

' Add a filter for inly uncleared activities

'-----------------------------------------------------------------

Dim aCleared As ActivityComparisonFilterCriteria = New ActivityComparisonFilterCriteria(New ActivityFieldDescriptor(ActivityField.IsCleared), ActivityComparisonFilterCriteria.Operation.Equals, 0)

                                        FilterArray.Add(aCleared)

                                        FilterArray.CopyTo(aFilter)

count = Me.HostFramework.Activities.GetActivitiesForCompany(Nothing, aFilter, Me.HostApplication.ApplicationState.CurrentCompany, Me.HostFramework.Activities.MIN_SMALL_DATE_TIME, Me.HostFramework.Activities.MAX_SMALL_DATE_TIME, FirstInstanceRestriction.FirstUnclearedOccurrence, True).Count

 

Here is the stack.

ROUTINE:       CurrentTab As TabPage

TARGET:        GetActivityInstancesForCompany

TYPE:          System.NullReferenceException

MESSAGE:       Object reference not set to an instance of an object.

SOURCE :       Act.Framework

PLUGIN:        Act.Framework

VERSION:       Act.Framework

ACT:           14.1.108.0

SOURCE:        Act.Framework

VERSION:       14.1.108.0 STACK:         at Act.Framework.Activities.ActivityManager.GetActivityInstancesForCompany(ActivitySortCriteria sortCriteria, IActivityFilterCriteria[] filterCriteria, ActivityAccessor[] accessors, Company company, DateTime startRange, DateTime endRange, RetrievalMode retrievalMode, Boolean restrictToFirstOccurrence, FirstInstanceRestriction firstOccurrenceRestrictionType, Int32 batchSize, Boolean deferInitialLoad)    at Act.Framework.Activities.ActivityManager.GetActivitiesForCompany(ActivitySortCriteria sortCriteria, IActivityFilterCriteria[] filterCriteria, Company company, DateTime startRange, DateTime endRange, FirstInstanceRestriction showFirstRestiction, Boolean deferInitialLoad)    at Durkin.Custom.TabIndicators.TabIndicators.HostApplication_CurrentCompanyChanged(Object sender, EventArgs e)

TIME:          8/25/2013 3:19:34 PM ACT NAME:      ActSage, Version=14.1.108.0, Culture=neutral, PublicKeyToken=ebf6b2ff4d0a08aa

---- Stack Trace ---- Stack:0:    Durkin.Common.Utilities.LogError.EnhancedStackTrace()        ActSage.exe: N 00083 Stack:1:    Durkin.Common.Utilities.LogError.Write(myException As Exception, sRoutine As String, sPluginName As String, sPluginVersion As String, sEmailFromAddress As String, sFromFullName As String)        ActSage.exe: N 07971 Stack:2:    Durkin.Common.Utilities.LogError.Write(myException As Exception, sDescription As String)        ActSage.exe: N 00116 Stack:3:    Durkin.Custom.TabIndicators.TabIndicators.HostApplication_CurrentCompanyChanged(sender As Object, e As EventArgs)        ActSage.exe: N 09138 Stack:4:    System.EventHandler.Invoke(sender As Object, e As EventArgs)        ActSage.exe: N 00000 Stack:5:    Act.UI.ActApplication.OnCurrentCompanyChanged()        ActSage.exe: N 00085 Stack:6:    Act.UI.ActApplicationState.set_CurrentCompany(value As Company)        ActSage.exe: N 00084 Stack:7:    Act.UI.Companies.Views.CompanyDetailView.OnCompanyChange()        ActSage.exe: N 00458 Stack:8:    Act.UI.Companies.Views.CompanyBaseView.BindToPositionChange()        ActSage.exe: N 00128 Stack:9:    Act.UI.Companies.Views.CompanyBaseView.OnViewActivate()        ActSage.exe: N 00023 Stack:10:    Act.UI.Companies.Views.CompanyDetailView.OnViewActivate()        ActSage.exe: N 01071 Stack:11:    Act.UI.ActApplication.LoadView(viewPacket As ViewPacket)        ActSage.exe: N 00996 Stack:12:    Act.UI.UICompanyManager.LoadDetailPacket(loadView As Boolean)        ActSage.exe: N 00137 Stack:13:    Act.UI.UICompanyManager.ShowDetailView()        ActSage.exe: N 00037 Stack:14:    Durkin.UI.Impact.usrNavButtons.btnImage2_Click(sender As Object, e As EventArgs)        usrNavButtons.vb: line 0554, col 09, IL 0048 Stack:15:    System.Windows.Forms.Control.OnClick(e As EventArgs)        ActSage.exe: N 00112 Stack:16:    DevExpress.XtraEditors.BaseButton.OnClick(e As EventArgs)        ActSage.exe: N 00126 Stack:17:    DevExpress.XtraEditors.DropDownButton.OnClick(e As EventArgs)        ActSage.exe: N 00038 Stack:18:    DevExpress.XtraEditors.BaseButton.OnMouseUp(e As MouseEventArgs)        ActSage.exe: N 00260 Stack:19:    DevExpress.XtraEditors.DropDownButton.OnMouseUp(e As MouseEventArgs)        ActSage.exe: N 00230 Stack:20:    System.Windows.Forms.Control.WmMouseUp(m As Message&, button As MouseButtons, clicks As Int32)        ActSage.exe: N 00655 Stack:21:    System.Windows.Forms.Control.WndProc(m As Message&)        ActSage.exe: N 02181 Stack:22:    DevExpress.Utils.Controls.ControlBase.WndProc(m As Message&)        ActSage.exe: N 00124 Stack:23:    DevExpress.XtraEditors.DropDownButton.WndProc(m As Message&)        ActSage.exe: N 00248 Stack:24:    System.Windows.Forms.ControlNativeWindow.OnMessage(m As Message&)        ActSage.exe: N 00016 Stack:25:    System.Windows.Forms.ControlNativeWindow.WndProc(m As Message&)        ActSage.exe: N 00049 Stack:26:    System.Windows.Forms.NativeWindow.DebuggableCallback(hWnd As IntPtr, msg As Int32, wparam As IntPtr, lparam As IntPtr)        ActSage.exe: N 00087 Stack:27:    System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(msg As MSG&)        ActSage.exe: N 00000 Stack:28:    System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(dwComponentID As Int32, reason As Int32, pvLoopData As Int32)        ActSage.exe: N 00590 Stack:29:    System.Windows.Forms.ThreadContext.RunMessageLoopInner(reason As Int32, context As ApplicationContext)        ActSage.exe: N 00375 Stack:30:    System.Windows.Forms.ThreadContext.RunMessageLoop(reason As Int32, context As ApplicationContext)        ActSage.exe: N 00097 Stack:31:    System.Windows.Forms.Application.Run(mainForm As Form)        ActSage.exe: N 00049 Stack:32:    Act.Application.SingletonApp.Run(startupForm As Form)        ActSage.exe: N 00114 Stack:33:    Act.Application.Act.Main(args As String[])        ActSage.exe: N 03341

 

ExceptionToString:Exception Source:      Act.Framework Exception Type:        System.NullReferenceException Exception Message:     Object reference not set to an instance of an object. Exception Target Site: GetActivityInstancesForCompany

---- Stack Trace ---- Stack:0:    Act.Framework.Activities.ActivityManager.GetActivityInstancesForCompany(sortCriteria As ActivitySortCriteria, filterCriteria As IActivityFilterCriteria[], accessors As ActivityAccessor[], company As Company, startRange As DateTime, endRange As DateTime, retrievalMode As RetrievalMode, restrictToFirstOccurrence As Boolean, firstOccurrenceRestrictionType As FirstInstanceRestriction, batchSize As Int32, deferInitialLoad As Boolean)        ActSage.exe: N 00064 Stack:1:    Act.Framework.Activities.ActivityManager.GetActivitiesForCompany(sortCriteria As ActivitySortCriteria, filterCriteria As IActivityFilterCriteria[], company As Company, startRange As DateTime, endRange As DateTime, showFirstRestiction As FirstInstanceRestriction, deferInitialLoad As Boolean)        ActSage.exe: N 00067 Stack:2:    Durkin.Custom.TabIndicators.TabIndicators.HostApplication_CurrentCompanyChanged(sender As Object, e As EventArgs)        ActSage.exe: N 03693

 

 

Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Bug in GetActivitiesForCompany

Found a workaround!

The first parameter of sort can not be blank.

Most other methods in the Act! SDK will work with either the sort and/or filter criteria being empty.

But is these two methods you must provide a sort or act! will throw an error.

 

So create a sort criteria as such....   

Dim occurDate As ActivityFieldDescriptor = New ActivityFieldDescriptor(ActivityField.OccurDate)

Dim aSort As ActivitySortCriteria = New ActivitySortCriteria(occurDate, System.ComponentModel.ListSortDirection.Ascending)

 

And add it to GetActivitiesForCompany()

 

count = Me.HostFramework.Activities.GetActivitiesForCompany(aSort, aFilter, Me.HostApplication.ApplicationState.CurrentCompany, Me.HostFramework.Activities.MIN_SMALL_DATE_TIME, Me.HostFramework.Activities.MAX_SMALL_DATE_TIME, FirstInstanceRestriction.FirstUnclearedOccurrence, True).Count