Community
Showing results for 
Search instead for 
Do you mean 
Reply

Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event

Astute Commentator
Posts: 168
Country: United States

Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event

Mathew,

 

Sorry to keep asking questions. I think I am almost done.

 

How does one create a DeletedDates instance for a recurring event? For example, I want to add a date to the DeletedDates object so that it does not display .

 

Thanx in advance.

 

T

Employee
Posts: 1,163
Country: USA

Re: Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event

DeletedDates is a public property of an Activity object, it's readonly, so programmaticaly it would not be possible to add a date to this property directly, however clearing an activity adds a entry to the DeletedDates collection for the instance that is cleared and it appears the FirstOccurrence.

Matthew Wood
Act! SDK Support
Community Moderator
Astute Commentator
Posts: 168
Country: United States

Re: Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event

DeleteDates keeps track of the items that have been erased and individually modified in a Recurring Activity. It must be used by by the calendar display mechanism.

 

Do you have a piece of code that shows how to add a date directly to the DeleteDates array?

 

BTW, FirstOccurence is pretty much a dud property on a Recurring Activity (from what I've seen). If you erase the original Recurring Activity, the FirstOccurence dissappears from the Activity series. AND if you retrieve Activities with FirstOccurence filter enabled, it retrieves all the activities, whether they are FirstOccurence or not. So programmatically, you can't rely of FirstOccurence in any form or matter.

 

 

Employee
Posts: 1,163
Country: USA

Re: Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event


Thatch2 wrote:

 

Do you have a piece of code that shows how to add a date directly to the DeleteDates array?

  

 



Not possible, as I mentioned earlier it's a read only property.

Matthew Wood
Act! SDK Support
Community Moderator
Astute Commentator
Posts: 168
Country: United States

Re: Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event

So how does the calendar erase a single event from a recurring activitiy? For example, if you right click on an individual instance, you have the option to erase it and it dissapears from the recurring activity. The reason that it dissapears is that the date is added to the DeletedDates array. Maybe I did not ask correctly, so I'll try again:

 

  - Do you have a piece of code that shows the mechanism when you erase on an individual event of a recurring series? On the calendar, it has access to the Recurring Activity, and it then provides the choice of erasing the series or the individual event. I just want the piece that erases the individual instance.

 

Basically, erasing the individual instance just adds the date selected on the calendar to the DeletedDates array.

 

Could you please provide me with that piece. It should be a quite short piece of code.

 

Thank you in advance.

 

T

 

 

Employee
Posts: 1,163
Country: USA

Re: Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event

Erasing an activity that is part of a series is the same as deleting one individually. The ActivityClass has a DeleteActivity method that accepts an activity object, it's accessor and a a bool value indicating whether or not you want to remove all occurrences.

 

ActApp.ActFramework.Activities.DeleteActivity(a, a.Organizer, false);

 

a is an activity. I'm not completely certain if this is what your looking for, hope it helps.

Matthew Wood
Act! SDK Support
Community Moderator
Astute Commentator
Posts: 168
Country: United States

Re: Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event

I tried that. However, in my case, it does not work. It deletes the activity on the first instance of the activity or on the date the activity starts. I want to be able to delete the activity on a particular instance date i.e. like on the calendar, that it deletes the activity on the selected date. What parameter does the calendar set in order to do it. I've tried OccurTime but that does not work either.

 

T

Employee
Posts: 1,163
Country: USA

Re: Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event

I'd have to see how your getting the ActivityList to be certain, but I just tested this and was able to delete an instance froma series. This test was done in an empty database with one user and a single weekly recurring activity series.

 

 

Contact c = ActApp.ApplicationState.CurrentContact;
ActivityList al = ActApp.ActFramework.Activities.GetActivitiesForContact(c, FirstInstanceRestriction.None);
Activity a = al[2];

ActApp.ActFramework.Activities.DeleteActivity(a, a.Organizer, false);

This example left the first occurrence and the next occurrence remained and the third was erased. 

Matthew Wood
Act! SDK Support
Community Moderator
Astute Commentator
Posts: 168
Country: United States

Re: Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event

Thanx.

 

Expanding the series is quite processor intensive and slow, specially if you have a lot of recurring events, including daily events. If you expand a single daily series, you could get thousands of events and then you'll have to go through the chain to find the correct one to erase.

 

I was trying to avoid hogging down ACT! just to clear a single instance of a recurring event. There has to be a better way to do it. I don't think the calendar does that when it tries to clear a single instance.

 

T

 

Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Creating a DeletedDates item and/or creating a ClearedDates item on Recurring Event

It sounds like you are editing the activity series and trying to alter its recurrence pattern? That can be done but the recurrence patterns of an activity are very complex. I spent many days understanding ACT! Recurrence patterns and only because I wrote a calendar program in my past did I comprehend it.

 

Here is some sudo code for changing the recurrence pattern to weekly:

 

Dim NewRecurSpec As New Act.Framework.Activities.ActivityRecurSpec

NewRecurSpec.Period = Act.Framework.Activities.ActivityRecurPeriod.Weekly

NewRecurSpec.DayType = Act.Framework.Activities.ActivityRecurDayType.Typed

NewRecurSpec.Frequency = X

NewRecurSpec.IsEndless =True

 

 

I think you want to get the instance of the specific activity then delete it. Since it is a part of a series the series will be updated automatically.

 

Hope this helps

-- Jim Durkin