Community
Showing results for 
Search instead for 
Do you mean 
Reply

Filtering recurring activities

Champion Listener
Posts: 32
Country: Canada

Filtering recurring activities

Hello,

 

I need to filter activities by date range. Regular activities are fine.

But i have a problem filtering recurring activities. I want to get only activities that have instances in defined date range. I use this code:

 

startDate and endDate are dates of the range i'd like to get activity instances.

                .......

               //create recurenddate date filter criteria
                ActivityFieldDescriptor recurEndDateField = HHCActFramework.Activities.GetFieldDescriptor( "RECURENDDATE" )as ActivityFieldDescriptor;
                ActivityDateFilterCriteria recurEndDateFilter = new ActivityDateFilterCriteria( recurEndDateField, startDate, endDate );
                filterList.Add( recurEndDateFilter );

                //create a recurperiod criteria
                ActivityFieldDescriptor recurPeriodField = HHCActFramework.Activities.GetFieldDescriptor( "RECURPERIOD" )as ActivityFieldDescriptor;
                ActivityComparisonFilterCriteria recurPeriodFilter = new ActivityComparisonFilterCriteria( recurPeriodField, Act.Framework.ComparisonFilterCriteria.Operation.NotEqual, recurPeriod );
                filterList.Add( recurPeriodFilter );

                IActivityFilterCriteria[] filterCriteria = (IActivityFilterCriteria[])filterList.ToArray( typeof( IActivityFilterCriteria ));
                ActivityFilterClause filterClause = new ActivityFilterClause( filterCriteria, Act.Framework.FilterClause.LogicalConnector.And );
                ActivityFilterClause[] filterClauses = new ActivityFilterClause[]{ filterClause };

                ........

recuringActivityList = ActFramework.Activities.GetActivitiesForContact( sortCriteria, filterClauses, contact, FirstInstanceRestriction.FirstOccurrence );

 

But, the code doesn't work as expected. I get less activities then Act! shows in Tasks list for the same date range.

 

I think that the problem might be in filtering by RECURENDDATE.

 

What is the field i need to filter by to get all recurring activities with instances in defined date range? How can i achieve this to get the same results as Act! Task list?

 

Thanks.

Katerina

 

 

 

 

Nickel Contributor
Posts: 175
Country: USA

Re: Filtering recurring activities

Just a quick thought after looking at the code. What happens if you change "FirstInstanceRestriction.FirstOccurrence" to "FirstInstanceRestriction.None"?

I'm not familiar with the FirstInstanceRestriction enumeration, but form the looks of it, you are only getting the first occurrence.
Champion Listener
Posts: 32
Country: Canada

Re: Filtering recurring activities

Yes, i only want first occurence. I tried with None too, but didn't make any change.

 

But i found the solution.

Instead adding date range in filter criteria, i removed recurEndDateFilter from filters and used another method from Act! to retrieve only instances in defined range. I use this method now:

 

recuringActivityList = ActFramework.Activities.GetActivitiesForContact(sortCriteria, filterRecurrentActivity, contact, filter.ActivityStartTime, filter.ActivityEndTime, FirstInstanceRestriction.FirstOccurrence);

 

And it works flawlessly. I get same set of recurring activities as Task list in Act!

 

Thanks.

Katerina